String is being escaped

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 18-Jun-2010 15:26:37   

Hi there,

I have the following value for a varchar column in SQL Server: '\n' but when I read the value of the property mapped ot the column in the debugger its coming out as '\n'.

Why is it escaping the string and how do I stop it?

Cheers, Ian.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Jun-2010 20:52:28   

What is the value stored in db? What do you want to store? The problem is in save or fetch?

David Elizondo | LLBLGen Support Team
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 18-Jun-2010 21:15:57   

I've got this in the db...

@ {Name}\n{Address1}, {Town}, {County}, {Country}, {PostCode}.

...and its coming out with this...

@ {Name}\n{Address1}, {Town}, {County}, {Country}, {PostCode}.

So the newline is not doing anything.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Jun-2010 06:48:31   

You want a NEWLINE stored in db, but you don't have that. You have a "/n" character that is automatically escaped when read back. What you should do is

A. store the string as

myEntity.MyStringInfo = "abcd/n";

Then when you fetch the data is presented as expected. Tip: when you store a NEWLINE it's not visible/readable in db text.

B. Or convert/transform/replace the fetched string to get what you want.

I'm not expert in string escaped characters, but few tests I did worked like I just said.

David Elizondo | LLBLGen Support Team
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 19-Jun-2010 15:19:14   

I think I get it. Thanks.