我试图让一个换行符存储在MS SQL数据库中 [英] I am trying to get a line break to store in a MS SQL database
本文介绍了我试图让一个换行符存储在MS SQL数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将换行符存储到数据库中。
我使用列表框添加项目,每个项目都应该在新行上打印。例如
I am trying to get a line break to store in a database.
I am using a listbox to add items each item should be printed on a new line. eg
Modify existing software.
Design and develop software systems.
Resolve customer problems.
然而它的印刷
however its printing
Modify existing software.Design and develop software systems.Resolve customer problems.
我尝试过什么:
What I have tried:
string duties = "";
foreach (ListItem item in LBDuties.Items)
{
duties = duties + item + System.Environment.NewLine;
}
Response.Write(duties);
推荐答案
新行是ASCII的东西,当你创建HTML时它不遵守ASCII新行,你需要HTML新行(< br />)
New line is an ASCII thing, when you are creating HTML it does not obey ASCII new lines, you need HTML new lines (<br/>)
Response.Write(duties.Replace("\r\n", "<br/>"));
也使用StringBuilder而不是字符串连接。
Also use a StringBuilder rather than string concatination.
这篇关于我试图让一个换行符存储在MS SQL数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文