Solved

Insert a line break into a sql statement

Posted on 2006-11-29
6
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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.

734 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