有人可以帮我宣布一个标量变量吗?我真的不明白这个Scalar Variable宣言.
下面是导致我的异常的代码.
int customer_Id;
int.TryParse(customer_IDTextBox1.Text, out customer_Id);
string SQL = @"UPDATE Customer
SET Customer_Name = @customer_Name
WHERE Customer_ID = @customer_Id";
SqlCommand sqlCommand = new SqlCommand(SQL, sqlConnection);
sqlCommand.Parameters.AddWithValue("@customer_Name", customer_Name);
sqlConnection.Open();
sqlCommand.ExecuteNonQuery();
Run Code Online (Sandbox Code Playgroud)
您只将@customer_Name变量声明为参数.
添加行
sqlCommand.Parameters.AddWithValue("@customer_Id", customer_Id);
Run Code Online (Sandbox Code Playgroud)
在你当前的AddWithValue路线下.