在多行文本框中输入内容,然后更新数据表, 经常会出现“字符串的语法错误,在查询表达式"'什么什么 中"”, ,但有时就不会。。。我找了好久了,就是不知道到底是错在哪。。。部分代码如下:
//更新数据表(下面的部分是放在按钮事件里的)
datacon();//链接数据库
OleDbCommand rtCOMD=thisCON.CreateCommand();
rtCOMD.CommandText="Update message set theimg='okhf.gif',hfzz='"+this.hfauth.Text+"',hftime='"+tn+"',hfct='"+this.hfcontent.Text+"',hftt='"+this.theht.Text+"',hfstate='ok' where id="+Convert.ToInt32(ViewState["thekey"].ToString());//按ID更新数据表
rtCOMD.ExecuteNonQuery();
/////////
Stack Trace:
OleDbException (0x80040e14): 字符串的语法错误 在查询表达式 ''嗯。。。。。。。。。。。。' 中。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +267
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +192
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +48
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +106
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +108
ASP.kaoyang_mess_response_aspx.btnok_Click(Object Sender, EventArgs e) in e:\Vhost\webroot\xiniaogzs\www\kaoyang\mess\response.aspx:129
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +105
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102