sql有不少转义字符,需要注意一下,转换一下再存进去就Ok了
public string EnCode(string content)
{
string str1=content.Replace("<","<");
string str2=str1.Replace(">",">");
string str3=str2.Replace("'","'");
string str4=str3.Replace(" "," ");
string str5=str4.Replace("/r/n","<br>");
string str6=str5.Replace("/"",""");
string str7=str6.Replace("&","&");
return str7;
}
public string UnCode(string content)
{
string str1=content.Replace("&","&");
string str2=str1.Replace(""","/"");
string str3=str2.Replace("<br>","/r/n");
string str4=str3.Replace(" "," ");
string str5=str4.Replace("'","'");
string str6=str5.Replace(">",">");
string str7=str6.Replace("<","<");
return str7;
}
}