 |
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

July 5th, 2004, 05:29 AM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
HELP Inserting Carriage Return
Help, I've been trying for days to get this one off the ground - I need to get carriage returns and bullet points into my access database from a form.
Story so far: Ive created the form which (form.asp) which connects to my db (form.mdb). When retrieving the information, the carriage returns dont come true. News is the name of the memofield.
Code:
<%
' Declaring variables
Dim rs, data_source, strText
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("form.mdb")
' Creating Recordset Object and opening the database
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "users", data_source, strText
strText = Rs("news")
strText = Replace(strTExt,vbCrLF,"<br>")
%>
I'd be grateful if someone could help. Please
|

July 5th, 2004, 06:28 AM
|
Friend of Wrox
|
|
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
|
|
Are you using textarea to get the information "news"?
Om Prakash
|

July 5th, 2004, 06:31 AM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for your quick reply - I'm trying to retrive it from a memo field in the database.
The area which I want to draw the info into is:
<td colspan="5"><p class="bluetextmr"><%=rs("news") %></p></td>
|

July 5th, 2004, 05:25 PM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by om_prakash
Are you using textarea to get the information "news"?
Om Prakash
|
]
Sorry misunderstood initially, yes I am using the text area in the db - am assuming the user doesnt know html so cannot expect them to use coding in the form. I've tried all sorts of ways of replacing but cant seem to crack it. Any help appreciated. Thanks.
|

July 5th, 2004, 05:33 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Try this
Code:
strText = Replace(strTExt,chr(10),"<br>")
Or
Code:
strText = Replace(strTExt,chr(13),"<br>")
Actually, you should be converting them to <br> tags while inserting into DB, that is when your code should replace vbCRLFs to <br>s
Quote:
quote:strText = Replace(strTExt,vbCrLF,"<br>")
|
But still it depends on the usage, if you are not using these data for the purpose other than displaying on the webpages, then you can replace that into <BR> tags while inserting into DB, else you should be doing it the way I mentioned above.
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|

July 5th, 2004, 05:48 PM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OMG Vijay - Its worked - thank you ever so much. One happy bunny here... :D
|

July 5th, 2004, 06:07 PM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
[quote]quote: Originally posted by happygv
Actually, you should be converting them to <br> tags while inserting into DB, that is when your code should replace vbCRLFs to <br>s
Quote:
strText = Replace(strTExt,vbCrLF,"<br>")
|
But still it depends on the usage, if you are not using these data for the purpose other than displaying on the webpages, then you can replace that into <BR> tags while inserting into DB, else you should be doing it the way I mentioned above.
------------------------
Hope you dont mind me asking - I did try to put this in the submit form as such previously
Function ChkString(string)
If string = "Chr(13)" Then string = " "
ChkString = Replace(string, "Chr(13)", "<br>")
End Function
but I couldn't get it to work as it is a form to submit to the database just to be viewed as an html page.
Thanks. Deb
|

July 5th, 2004, 06:51 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
You should not use "" around chr(13)
You can also use vbCRLF there instead of chr(13), but still without "" around it.
Code:
ChkString = Replace(string, Chr(13), "<br>")
or
Code:
ChkString = Replace(string, vbCRLF, "<br>")
Cheers!
_________________________
- Vijay G
Strive for Perfection
|

July 5th, 2004, 08:36 PM
|
Registered User
|
|
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
It makes sense now. Thanks ever so much Vijay. Phew!
|
|
 |