System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
在ASP.NET中添加一条记录时总是出现这样的错误提示异常详细信息:System.Data.SqlClient.SqlException:第1行:'8'附近有语法错误。源...
在ASP.NET中添加一条记录时 总是出现这样的错误提示
异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '8' 附近有语法错误。
源错误:
行 53:
行 54:
行 55: int i=mycmd.ExecuteNonQuery ();
行 56: try
行 57: {
...
堆栈跟踪:
[SqlException (0x80131904): 第 1 行: '8' 附近有语法错误。]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +109
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +57
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +207
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2433
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +190
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +256
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +117
Reg.btn_agree_Click(Object sender, EventArgs e) in f:\dayi\register\Reg.aspx.cs:55
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +78
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +100
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2863
我的数据库连接字符串是: string connectionString = Convert.ToString(ConfigurationManager.ConnectionStrings["dayieduConnectionString"]);
SqlConnection conn = new SqlConnection(connectionString );
已经在web.config中添加了如下节:
<connectionStrings>
<add name="dayieduConnectionString" connectionString="Data Source=ADMIN22;Initial Catalog=dayiedu;Integrated Security=SSPI"
providerName="System.Data.SqlClient" />
</connectionStrings>
不知道到底是哪里出了问题,高手请教!
我的SQL语句是 string strSql = "insert into users(userName,userPassword,sex,birthday,email,question,answer,validateCode) values('" + tbx_account.Text + "','" + tbx_pwd.Text + "','" + rbl_sex.SelectedItem.Text +"',"+DateTime .Now +",'"+email .Text +"','"+dpl_question .SelectedItem .Text +"','"+tbx_answer .Text +"','"+tbx_chkcode .Text +"'";
这是一条用来用户注册的语句。
把int i=mycmd.ExecuteNonQuery ();放入try还是不行,出现同样的错误信息。 展开
异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '8' 附近有语法错误。
源错误:
行 53:
行 54:
行 55: int i=mycmd.ExecuteNonQuery ();
行 56: try
行 57: {
...
堆栈跟踪:
[SqlException (0x80131904): 第 1 行: '8' 附近有语法错误。]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +109
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +57
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +207
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2433
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +190
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +256
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +117
Reg.btn_agree_Click(Object sender, EventArgs e) in f:\dayi\register\Reg.aspx.cs:55
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +78
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +100
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2863
我的数据库连接字符串是: string connectionString = Convert.ToString(ConfigurationManager.ConnectionStrings["dayieduConnectionString"]);
SqlConnection conn = new SqlConnection(connectionString );
已经在web.config中添加了如下节:
<connectionStrings>
<add name="dayieduConnectionString" connectionString="Data Source=ADMIN22;Initial Catalog=dayiedu;Integrated Security=SSPI"
providerName="System.Data.SqlClient" />
</connectionStrings>
不知道到底是哪里出了问题,高手请教!
我的SQL语句是 string strSql = "insert into users(userName,userPassword,sex,birthday,email,question,answer,validateCode) values('" + tbx_account.Text + "','" + tbx_pwd.Text + "','" + rbl_sex.SelectedItem.Text +"',"+DateTime .Now +",'"+email .Text +"','"+dpl_question .SelectedItem .Text +"','"+tbx_answer .Text +"','"+tbx_chkcode .Text +"'";
这是一条用来用户注册的语句。
把int i=mycmd.ExecuteNonQuery ();放入try还是不行,出现同样的错误信息。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询