HighDots Forums  

No line breaks returned from SQL to ASP page

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss No line breaks returned from SQL to ASP page in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
_Mike
 
Posts: n/a

Default No line breaks returned from SQL to ASP page - 10-29-2005 , 09:06 PM






I'm not getting line breaks from my SQL table when I add dynamic text to page.

Input into SQL database like this:

test
test
test

But I get this on my dynamic text page:

test test test

I'm using .asp and SQL. text datatype

Any advice?


Reply With Quote
  #2  
Old   
middletree
 
Posts: n/a

Default Re: No line breaks returned from SQL to ASP page - 10-29-2005 , 09:31 PM






When you type in a return (hit the enter key) in a textarea field, it puts
in an unseen character called carriage-return, line-feed. Its human-readable
form is &vbcrf;

When you display text in HTML (such as when you pull it from the database
for display) you need to take the value in that field and do an ASP replace
function, replacing the vbcrlf; with <BR>, which is what your browser
understands.

In ASP, the replace function works like this:

Replace(value you're working with, "the thing to be replaced", "the thing
you're replacing it with")

So if you pulled something from the database and put it into a variable
called strNews, then your code would be

strNews = Replace(strNews,"vbcrlf;","<br>")

The last two have to be in quotes.


"_Mike" <webforumsuser (AT) macromedia (DOT) com> wrote

Quote:
I'm not getting line breaks from my SQL table when I add dynamic text to
page.

Input into SQL database like this:

test
test
test

But I get this on my dynamic text page:

test test test

I'm using .asp and SQL. text datatype

Any advice?




Reply With Quote
  #3  
Old   
_Mike
 
Posts: n/a

Default Re: No line breaks returned from SQL to ASP page - 10-29-2005 , 10:44 PM



Thanks MiddleTree. Works great.


<%=(rsName.Fields.Item("content").Value).replace (/\n/g,"<BR>\n")%>

Reply With Quote
  #4  
Old   
_adrian
 
Posts: n/a

Default Re: No line breaks returned from SQL to ASP page - 10-30-2005 , 02:28 PM



Odd.. that doesn't work for me.. [grumble]



Reply With Quote
  #5  
Old   
Lionstone
 
Posts: n/a

Default Re: No line breaks returned from SQL to ASP page - 10-31-2005 , 10:18 AM



What he wrote there is JScript. The VBScript version would be
<%=Replace(yourString,vbCrLf,"<br>")%>.

"_adrian" <test @ test.com> wrote

Quote:
Odd.. that doesn't work for me.. [grumble]




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.