Solved

Insert a line break into a sql statement

Posted on 2006-11-29
6
345 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 143

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

Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

679 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