Save new string data characters from TextBox to SQL Server

I use a Multi-line TextBox through which users can enter data that will be saved in a SQL Server 2008 database. There is another process that reads this data from a table and writes it to a text file.

Problem: If the data entered by users in the text field contains <Enter> from the keyboard, they save the database with some spaces, replacing <Enter> .

Some, as if I were reading the same data in a text box on a web page, it displays correctly.

But if my second process, which reads data from a database and prints to a text file, it does not save the text format properly. It does not save <Enter> in the data printed in a text file.

Can someone help me save the <Enter> in the generated text file?

+4
source share
1 answer

It looks like your <Enter> stored in the database, since it works correctly when re-outputting to a text field.

My guess is that the problem is either that they write them to a text file, removing the characters CR and LF, or your text reader does not understand them.

If you open a text file in Notepad ++, and then go into view mode → show character and make sure "Show line ending" is checked, you should see if the CR and LF characters at the end of the line are saved when writing to a text file.

+3
source

Source: https://habr.com/ru/post/1341843/


All Articles