错误:
System.Data.SqlClient.SqlException(0x80131904):列名无效 '地址'。在System.Data.SqlClient.SqlConnection.OnError(SqlException exception,Boolean breakConnection,Action 1 wrapCloseInAction)at System.Data.SqlClient.SqlInternalConnection.OnError(SQLEXCEPTION exception,Boolean breakConnection,Action 1 wrapCloseInAction)at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,Boolean callerHasConnectionLock,Boolean asyncClose)at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler,SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj,布尔& dataReady)at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior,String resetOptionsString)at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(的CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean async,Int32超时,任务& task,Boolean asyncWrite,SqlDataReader ds,Boolean describeParameterEncryptionRequest)at System.Data.SqlClient.SqlCommand.RunExecuteReader(的CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String 方法,TaskCompletionSource 1完成,Int32超时,任务&任务, 布尔asyncWrite)at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion,String methodName,Boolean sendToPipe,Int32 timeout, 布尔asyncWrite)at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()at reg.Button1_Click(Object sender,EventArgs e)in c:\ Users \ Urban \ Desktop \ Gledalisce \ reg.aspx.cs:第51行 ClientConnectionId:398be50f-0c3e-442f-b15c-343c1971f7db错误 数:207,状态:1,类别:16
这是我在尝试提交regestration表单时遇到的错误。
这是我正在使用的代码的一部分。
protected void Button1_Click(object sender, EventArgs e)
{
if (IsPostBack)
{
try
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegestrationConnectionString"].ConnectionString);
conn.Open();
string insertQuery = "insert into [User] (ID_username,password,name,surname,address,city,post_num,mobile_num,email,dateOFbirth,sex,pickUPcode) values (@username,@password,@name,@surname,@address,@city,@post_num,@mobile_num,@email,@dateOFbirth,@sex,@pickUPcode)";
SqlCommand com = new SqlCommand(insertQuery, conn);
com.Parameters.AddWithValue("@username",username.Text);
com.Parameters.AddWithValue("@password", password.Text);
com.Parameters.AddWithValue("@name", name.Text);
com.Parameters.AddWithValue("@surname", surname.Text);
com.Parameters.AddWithValue("@address", address.Text);
com.Parameters.AddWithValue("@city", city.Text);
com.Parameters.AddWithValue("@post_num", post_num.Text);
com.Parameters.AddWithValue("@mobile_num", mobile_num.Text);
com.Parameters.AddWithValue("@email", Email.Text);
com.Parameters.AddWithValue("@dateOFbirth", date_birth.Text);
com.Parameters.AddWithValue("@sex", sex.Text);
com.Parameters.AddWithValue("@pickUPcode", code.Text);
com.ExecuteNonQuery();
Response.Write("Regestracija je uspela!");
Response.Redirect("admin.aspx");
conn.Close();
}
catch (Exception ex) { Response.Write("Napaka: " + ex.ToString()); }
}
}
感谢任何可以帮助我的人!
答案 0 :(得分:0)
您的address
表格中似乎没有名为User
的列。