?
Solved

How to add a CR LF on SQL Server field and show as a new line in C# textbox

Posted on 2009-12-20
4
Medium Priority
?
457 Views
Last Modified: 2013-12-17
I need to show in C# windows forms , in a multiline textbox I need to show the CR + LF that is stored in field.

In SQL Server I added the lines by doing the following
Update Table1 Set
COmment = comment + ' ' + char(13) + char(10) + @Comment

However when I view it in the C# , it becomes one line, what do I have to do to make it work?

Any help will be great.

Noel
0
Comment
Question by:hongning2009
4 Comments
 
LVL 19

Expert Comment

by:elimesika
ID: 26092546
HI

If you are just displaying this in GUI you should use


Update Table1 Set
COmment = comment + '\r\n'  + @Comment

Open in new window

0
 
LVL 11

Accepted Solution

by:
lenordiste earned 2000 total points
ID: 26092678
\r\n is exactly the same thing as char(13) and char(10) which is exactly the same thing as Environment.NewLine on a windows plateform...

Your solution looks fine Noel and there's no reason why your textbox doesn't show multiple lines. Are you sure you set "TextBox.MultiLine = True" correctly? Maybe you should inspect what your sql select returns and make sure you do have those CRLF chars in the result.
0
 
LVL 10

Expert Comment

by:anv
ID: 26094785
It should be '\r\n' along with TextBox.MultiLine = True
0
 
LVL 7

Expert Comment

by:aplusexpert
ID: 26095320
Use "\n" to move on next line or for carriage return.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

807 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