Solved

Insert a line break into a sql statement

Posted on 2006-11-29
6
342 Views
Last Modified: 2007-12-19
Ok, here's the deal...

I have an asp.net form where people can update comments.  The form updates to a sql db each time they submit the form.  What I want to do is add a line break before the update statement so that when I pull all the comments from the DB there is some spacing between each comment.  

Like so:

11/28/2006 8:40:43 AM The sleek HP iPAQ hw6920 and hw6925 Mobile Messenger is a global communications device giving you the best in connectivity, productivity, and mobility to stay connected on the go.

11/29/2006 9:00:00 AM This world phone uses the Sprint CDMA/EV-DO networks in the U.S., Canada and Mexico, and roams on CDMA and/or GSM networks (voice) and GPRS networks (data) outside of North America


Right now I'm getting this:

11/28/2006 8:40:43 AM The sleek HP iPAQ hw6920 and hw6925 Mobile Messenger is a global communications device giving you the best in connectivity, productivity, and mobility to stay connected on the go. 11/29/2006 9:00:00 AM This world phone uses the Sprint CDMA/EV-DO networks in the U.S., Canada and Mexico, and roams on CDMA and/or GSM networks (voice) and GPRS networks (data) outside of North America

I tried adding vbCrLf and "<br>"  to the update statement but apparently ASP.net doesn't like having either of those in the update statement because it gives me an error about it being malicious code or something to that effect.  

Idea's ? Workarounds ?
0
Comment
Question by:intchauspe
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18037353
>but apparently ASP.net doesn't like having either of those
can you show the code you try to use?  the "<br>" stuff should work?...
0
 

Author Comment

by:intchauspe
ID: 18038550
txtDesc.Text & " " & Date.Now & " " & txtUpdates.Text & " " & "<BR>"

that will update but it add a literal <br> to the text like so:

11/29/2006 9:00:00 AM This world phone uses the Sprint CDMA/EV-DO networks in the U.S., Canada and Mexico, and roams on CDMA and/or GSM networks (voice) and GPRS networks (data) outside of North America <br>

then what happens is when I pull that text and try to add a new comment it freaks out because of the <br> and it gives the following error:

A potentially dangerous Request.Form value was detected from the client (ctl00$main$RepeaterDesc$ctl00$lblDesc="...vironment <BR>").



0
 

Author Comment

by:intchauspe
ID: 18039971
Figured it out......

txtDesc.Text & " " & Date.Now & " " & txtUpdates.Text & " " & CHAR(13)
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18042737
Since you are using VB.NET, I suspect you mean
txtDesc.Text & " " & Date.Now & " " & txtUpdates.Text & " " & CHR(13)

Or more simply:
txtDesc.Text & " " & Date.Now & " " & txtUpdates.Text & " " & vbCr
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 18077171
PAQd, 500 points refunded.

DarthMod
CS Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
tempdb latch contention 12 47
Alter table 4 23
Near realtime alert if SQL Server services stop. 20 53
SQL Server Question 5 25
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now