protected void btn1_Click(object sender, EventArgs e)
{
SqlConnection con = DB.creatConnection();
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "update voteDetails set votNum=votNum+1 where voteId=" + voteId + " and voteDetailsId=" + this.rbt1.SelectedValue.ToString();
cmd.ExecuteNonQuery();
con.Close();
}
(SQL中voteId voteDetailsId 是 int)
用户代码未处理 System.Data.SqlClient.SqlException
Message="第 1 行: '=' 附近有语法错误。"
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=15
LineNumber=1
Number=170
Procedure=""
Server="qiao"
State=1
StackTrace:
在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
在 System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
在 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
在 System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
在 vote.btn1_Click(Object sender, EventArgs e) 位置 f:\Program Files\qiao\vote.aspx.cs:行号 47
在 System.Web.UI.WebControls.Button.OnClick(EventArgs e)
在 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
在 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)