那是我的代码:
[WebMethod]
public static void SendChatMessage(string msg, int ToClient)
{
if (msg != null && ToClient != 0)
{
if (msg.Contains(":-)")) msg.Replace(":-)", "<img src='Styles/emojie/smile.png' /> ");
else if (msg.Contains(":-(")) msg.Replace(":-(", "<img src='Styles/emojie/sad.png' /> ");
else if (msg.Contains(":'-(")) msg.Replace(":'-(", "<img src='Styles/emojie/cry.png' /> ");
else if (msg.Contains(":-$")) msg.Replace(":-$", "<img src='Styles/emojie/shy.png' /> ");
int FromClientID = Convert.ToInt32(HttpContext.Current.Session["ClientID"]);
string query = "insert into chat (FROM_CLIENT,TO_CLIENT,CHAT_MSG) values (" + FromClientID + "," + ToClient + ",'" + msg + "')";
new SQLHelper(SQLHelper.ConnectionStrings.WebSiteConnectionString).Insert(query);
}
}
味精按原样发送到数据库,而不是替换我做错了什么?