Problem with line breaks

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ATR2000

    Problem with line breaks

    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


  • Alexey Smirnov

    #2
    Re: Problem with line breaks

    On Sep 19, 3:05 pm, "ATR2000" <some...@micros oft.comwrote:
    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.

    Comment

    Working...