简体   繁体   English

保留从TextBox到SQL Server的新行数据字符

[英]Preserve new line characters of data from TextBox to SQL Server

I am using Multi-line TextBox through which users will be able to enter data which will be saved on to the SQL Server 2008 database. 我正在使用多行TextBox,用户可以通过它输入将保存到SQL Server 2008数据库的数据。 There is an other process, which reads this data from the table and writes to a text file. 还有一个进程,它从表中读取此数据并写入文本文件。

Problem: If the data entered by users in text box contains <Enter> from keyboard, it is saving to the database with some spaces replacing the <Enter> . 问题:如果用户在文本框中输入的数据包含来自键盘的<Enter> ,它将保存到数据库,并用一些空格替换<Enter>

Some how if I read the same data to a text box on webpage, it is being displayed properly. 如果我将相同的数据读到网页上的文本框,它会如何正确显示。

But, if my second process that reads the data from database and prints to a text file, it is not keeping the text format properly. 但是,如果我的第二个进程从数据库读取数据并打印到文本文件,则它不能正确保留文本格式。 It is not retaining the <Enter> in the data being printed to text file. 它不会将正在打印的数据中的<Enter>保留在文本文件中。

Can any one help me how to retain the <Enter> in the text file being generated? 任何人都可以帮助我如何在正在生成的文本文件中保留<Enter>吗?

It sounds like your <Enter> is being retained in the database since it works correctly when you output to the textbox again. 听起来您的<Enter>保留在数据库中,因为当您再次输出到文本框时它可以正常工作。

My guess is that the problem is either in the process writing them to the textfile stripping out CR and LF characters or your text reader isn't achknowledging them. 我的猜测是,问题是在编写文本文件的过程中剥离CR和LF字符,或者您的文本阅读器不是他们的知识。

If you open the text file in Notepad++ and then go to view --> show symbol and make sure "Show End of Line" is checked you should be able to see if the CR and LF characters at the end of the line are preserved when written to the text file. 如果在Notepad ++中打开文本文件然后转到查看 - >显示符号并确保选中“显示行结束”,则应该能够查看行尾的CR和LF字符是否保留在写入文本文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM