Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old July 5th, 2004, 05:29 AM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

  #2 (permalink)  
Old July 5th, 2004, 06:28 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Are you using textarea to get the information "news"?

Om Prakash
  #3 (permalink)  
Old July 5th, 2004, 06:31 AM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>



  #4 (permalink)  
Old July 5th, 2004, 05:25 PM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

  #5 (permalink)  
Old July 5th, 2004, 05:33 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
  #6 (permalink)  
Old July 5th, 2004, 05:48 PM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OMG Vijay - Its worked - thank you ever so much. One happy bunny here... :D

  #7 (permalink)  
Old July 5th, 2004, 06:07 PM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

[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


  #8 (permalink)  
Old July 5th, 2004, 06:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
  #9 (permalink)  
Old July 5th, 2004, 08:36 PM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It makes sense now. Thanks ever so much Vijay. Phew!



Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking for a Carriage return darkhalf Classic ASP Databases 2 November 5th, 2007 06:15 AM
insert carriage return darkhalf Javascript 0 April 10th, 2007 02:42 PM
about carriage return... edu1980 XSLT 1 July 5th, 2006 04:11 AM
New Line/Carriage Return interrupt Javascript How-To 7 October 3rd, 2004 06:27 AM
Noobie Question on Carriage Return rsteph7 Beginning PHP 4 July 1st, 2003 04:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.