Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Memo field

  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Memo field

    How can I fix my code so that information inserted into the database will keep line breaks and not just be a jumbles bunch of text.

    Example: (here is how it is supposed to be)
    Leave Friday, June 25, early afternoon. Return late Saturday June 26. Cost: $79/adult, $59/youth, with lunch. Hotel & meals extra

    Contact Scott Alvis by June 6 if you would like to go. SAlvis@reclaim.com or 281.370.7228
    Here is how it shows up:
    Leave Friday, June 25, early afternoon. Return late Saturday June 26. Cost: $79/adult, $59/youth, with lunch. Hotel & meals extra Contact Scott Alvis by June 6 if you would like to go. SAlvis@reclaim.com or 281.370.7228
    Here is my code:
    Code:
    <%
    ' Declaring variables
    Dim rs, data_source, no
    no = 0
    data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _ 
    	Server.MapPath("admin/data/data.mdb")
    ' Creating Recordset Object and opening the database
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open "news", data_source
    ' Looping through the records to show all of them
    While Not rs.EOF
    Response.Write "<table width=""700"" border=""0"" cellspacing=""0"" cellpadding=""0""><tr><td valign=""top""><table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0""><tr><td class=""cat-2""> <table width=""300"" border=""0"" cellspacing=""0"" cellpadding=""0""><tr><td><table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"" class=""cat-border""><tr><td class=""cat-title"" width=""37""><img src=""images/cat_symbol.gif"" alt="""" width=""38"" height=""22"" /></td><td class=""frame-title"">"
    Response.Write rs("title")
    Response.Write "</td></tr></table></td></tr></table></td></tr><tr><td><table width=""90%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""0""><tr><td class=""boxtext"" valign=""top"">"
    Response.Write rs("post")
    Response.Write "</td></tr></table></td></tr></table><br /></td></tr></table>"
    no = no + 1
    rs.MoveNext
    Wend
    ' Done. Now close the Recordset
    rs.Close
    Set rs = Nothing
    	%>

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Change:
    Code:
    Response.Write rs("post")
    To:

    Code:
    Response.Write(Replace(rs("post"), vbCrLf, "<br />"))
    Assuming that the post field is your memo field.
    OracleGuy

  • #3
    New Coder
    Join Date
    Apr 2004
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yea, forgot to mention that. Thanks for your help. It is really appreciated. One more question, the way that my page is coded, is that a certain type of ASP? I see database connections done differently using SQL. Wha ti sthe difference?

    Thanks again for your help.

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Yes it is a certain type of ASP but it has nothing to do with what type of database you use. That's ASP/VBScript which is the most common form of ASP but ASP also supports using JScript instead.

    Your connection string is different because the data source is different, but assuming you used more standard SQL commands and stuff, you wouldn't have to change anything.

    Code:
    DRIVER={SQL SERVER}; SERVER=XAVIER; Uid=webuser; Pwd=*******; DATABASE=Mainframe
    The differences in the above connection string are most noteably the username, password, and database fields. Since your using a server instead of a file, you usually need a login and since it can have multiple databases, you need to specify which one you want to connect to. There are even more fields you can use, like there is the APP field which you can then specify the app name. This can add another layer of security to your server since you can set your DB to only allow say the webuser login to work if the app is "OurWebsite" so if someone where to get the username and guess the password, it still would give them access denied errors when logging in unless they knew an acceptable app name.
    OracleGuy

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Quote Originally Posted by oracleguy
    Change:
    Code:
    Response.Write rs("post")
    To:

    Code:
    Response.Write(Replace(rs("post"), vbCrLf, "<br />"))
    Assuming that the post field is your memo field.
    Using <pre></pre> tags is better because this will also preserve the tabs and multiple spaces.

    Response.Write "<pre>" & rs("post") & "</pre>"

    You can change the default appearance of the pre text using CSS.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •