...

View Full Version : Memo field



Ted Varnson
07-22-2004, 05:35 PM
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:

<%
' 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
%>

oracleguy
07-22-2004, 06:05 PM
Change:

Response.Write rs("post")

To:


Response.Write(Replace(rs("post"), vbCrLf, "<br />"))

Assuming that the post field is your memo field.

Ted Varnson
07-22-2004, 06:08 PM
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.

oracleguy
07-22-2004, 07:30 PM
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.


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.

glenngv
07-23-2004, 04:31 AM
Change:

Response.Write rs("post")

To:


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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum