Problem with line breaks

  • Thread starter Thread starter ATR2000
  • Start date Start date
A

ATR2000

I am having an issue with doing an insert or update of a record into a SQL
Server database from an ASP.NET. When I perform an insert or update of a
string with a line break with vbCrLf or Chr(13) & Chr(10) somehow the
Chr(13) gets removed or stripped off at the point of insert.

Example String:

a
b

The database shows it stored as "a" "square" "b". In ASCII Decimal Format,
values show as Chr(97) & Chr(10) & Chr(98) when it should be Chr(97) &
Chr(13) & Chr(10) & Chr(98). I have tried doing a replace just before the
Insert declaration to verify that all valid characters are there then insert
and still Chr(13) appears to get stripped out after inserted.

SAMPLE INSERT:

INSERT INTO MyTable (Field1, Field2) VALUES (@iField1, @iField2)

The web application calls a web service that performs this insert. Any
thoughts or ideas? Thanks in advance.

atr2000
 
I am having an issue with doing an insert or update of a record into a SQL
Server database from an ASP.NET.  When I perform an insert or update ofa
string with a line break with vbCrLf or Chr(13) & Chr(10) somehow the
Chr(13) gets removed or stripped off at the point of insert.

Example String:

a
b

The database shows it stored as "a" "square" "b".  In ASCII Decimal Format,
values show as Chr(97) & Chr(10) & Chr(98) when it should be Chr(97) &
Chr(13) & Chr(10) & Chr(98).  I have tried doing a replace just before the
Insert declaration to verify that all valid characters are there then insert
and still Chr(13) appears to get stripped out after inserted.

SAMPLE INSERT:

INSERT INTO MyTable (Field1, Field2) VALUES (@iField1, @iField2)

The web application calls a web service that performs this insert.  Any
thoughts or ideas?  Thanks in advance.

atr2000

I think the problem here could be due to a type of the field, encoding
in application and collation in the database. If you used UTF and char
or varchar data types, try to change the type to Nchar and Nvarchar.
If it's not the case, try to get the text back using SELECT FROM from
your .NET application to see what you really stored there.
 
Back
Top