How do I read new lines from a table column ?

R

Reddy

Hi,

I am using .NET 1.1 and SQLServer 2000. I have a table with some strings
with new line chars. E.g.: "This is line1.\nThis is line2.".

When I read this using a DataReader into a string, it is reading as
@"This is line1.\nThis is line2.". So, when I display it using a
MessageBox.Show(myMessage), it is showing "This is line1.\nThis is line2.".
Instead of:
This is line1.
This is line2.

When I inspected my string in vs.net, it is showing
@"This is line1.\nThis is line2."

How do I get rid off the @ sign or make it interpret newline as newline char
and not "\n" literal string?

I tried "This is line1.\\nThis is line2.".
It shows up as "This is line1.\\nThis is line2.".

thanks,
- Reddy
 
M

Miha Markic

Hi Reddy,

I guess your data already has characters '\' and 'n' instead of character
'\n'.
You might do a replace on returned string, like myMessage.Replace(@"\n",
"\n") which will convert all characters \ and n into newline character.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top