如何以给定格式将文本从文本框保存到SQL数据库 [英] How to save the text from textbox to sql database in the given format
问题描述
实际上我在sql数据库中保存文本时遇到一个问题。
示例: -
一个A人向B人发送消息下面在文本框中输入的文字
Hai
这是Ram
但是上面的文字正在保存在DataBase中,像Hai this is Ram,同时向B人展示它显示为Hai This is Ram。但我想要的是
Hai
这是Ram在数据库中它也应该像这样保存
是否有可能
Actually i am facing one problem while saving the text in sql database.
Example:-
One "A" person send a message to "B" person like below text entered in the textbox
"Hai
This is Ram"
But the above text is saving in DataBase like "Hai this is Ram" while displaying to "B" person it is showing like "Hai This is Ram". but what i want is
"Hai
This is Ram" in data base also it should save like this
Is it possible
推荐答案
我在保存到数据库时使用了下面的代码。我正在使用多行文本框,感谢每一位快速回答我的问题的人
I used below code while saving to database.here i am using multiline textbox thanks to every one who replied fastly for my question
txtMsgBody.InnerText.Replace("\r\n", "<br/>");
您是否尝试将其以html格式字符串存储到db?
另外,我在想,尝试怎么样,这样,
Hi,
Did you try storing it in html format string into db ?
Also, I was thinking, what about trying, like this,
"<pre>" + TextValue + "</pre>";
思想代码项目可以实现,但显然有更好的代码:) :)
问候,
Praneet
Thought code project does it, though with a better and a good code obviously :) :)
Regards,
Praneet
这篇关于如何以给定格式将文本从文本框保存到SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!