请教各位高手:文章保存到数据库的时候怎样同时保存他的段落格式!送高分!
/////我的提交保存代码。////
DateTime now=DateTime.Now ;
SqlConnection  MyConn=new SqlConnection(Application["MyConn"].ToString());
MyConn.Open ();
publishtime1=publishtime1 +"-"+yue+"-"+ri+"";
string str="insert into kyzt(title,province,sort,people,telephone,postcord,address,info,keyword,publishtime,time,sign ) values('"+title.Text+"','"+province.SelectedItem.Text +"','"+sort.SelectedItem.Text+"','"+people.Text +"','"+telephone.Text+"','"+postcord.Text+"','"+address.Text+"','"+info.Text+"','"+keyword.Text+"','"+publishtime1+"','"+now.Date+"',0)";
SqlCommand MyCmd=new SqlCommand (str,MyConn);
MyCmd.ExecuteNonQuery();
/////

解决方案 »

  1.   

    将你的文章的内容用下面这个方法转换一下:
    public static string TransStringTool(string aTransString)
    {
    aTransString = aTransString.Replace("&","&");
    aTransString = aTransString.Replace("<","&lt;");
    aTransString = aTransString.Replace(">","&gt;");
    aTransString = aTransString.Replace(" ","&nbsp;");
    aTransString = aTransString.Replace("\n","<br>");
    return aTransString;
    }
      

  2.   

    请问redcaff_l(热的咖啡):是在提交数据到数据库之前必须用上面的方法转换吗?
      

  3.   

    上面的问题的到解答,谢谢 redcaff_l(热的咖啡),请问还有什么方法,现在我的数据库中已经有大量的信息,是否只能一一修改吗?请各位高手帮忙。
      

  4.   

    用一个多行TextBox设置边框样式且只读同时更改鼠标,岂不是更简单。