请教C#将数据录入数据库的问题,只是提示有语法错误,实在不知道怎么解决了
这个错误该怎么解决呢,希望各位不吝赐教,谢谢各位!源代码
string strsqlert = "insert into project_apply_table (applier_type,applier_id,apply_time) values ('" + ddlAPPLYTYPE.SelectedItem.Text + "'','" + tbAPPLYID.Text + "',''" + tbAPPLYTIME.Text + "')";
SqlCommand cmdert = new SqlCommand(strsqlert, cn);
cmdert.ExecuteNonQuery();
在TEXTBOX输入id 23 后提交出现如下错误:
第 1 行: '23' 附近有语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '23' 附近有语法错误。
源错误:
行 27: string strsqlert = "insert into project_apply_table (applier_type,applier_id,apply_time) values ('" + ddlAPPLYTYPE.SelectedItem.Text + "'','" + tbAPPLYID.Text + "',''" + tbAPPLYTIME.Text + "')";
行 28: SqlCommand cmdert = new SqlCommand(strsqlert, cn);
行 29: cmdert.ExecuteNonQuery();
行 30:
行 31:
源文件: e:\WebSite3\control\project_apply.ascx.cs 行: 29
堆栈跟踪:
[SqlException (0x80131904): 第 1 行: '23' 附近有语法错误。]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +177
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +68
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2300
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +191
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +380
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +115
control_project_apply.btAPPLY_Click(Object sender, EventArgs e) in e:\WebSite3\control\project_apply.ascx.cs:29
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +97
System.Web.UI.WebControls.Button.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) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921