必须声明标量变量“@ ACK”。 [英] Must declare the scalar variable "@ACK".
本文介绍了必须声明标量变量“@ ACK”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SqlConnection con1 = new SqlConnection(server = DIPESH-PC\\SQLEXPRESS; uid = sa; pwd = rerf; database = E-REGISTRATION);
SqlConnection con1 = new SqlConnection("server=DIPESH-PC\\SQLEXPRESS;uid=sa;pwd=rerf;database=E-REGISTRATION");
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlCommand cmd1 = new SqlCommand("UPDATE feedback SET ACK=@ACK WHERE EMAIL_ID=@EMAIL_ID", con1);
if (!string.IsNullOrEmpty(TextBox6.Text))
{
cmd1.Parameters.AddWithValue("@ACK",TextBox6.Text);
}
con1.Open();
cmd1.ExecuteNonQuery();
con1.Close();
Label1.Text = " Data Updates Succesfully on " + System.DateTime.Now.ToShortDateString();
}
可以告诉我为什么我会收到错误'必须声明标量变量'@ACK'。
Can somone please tell me why I get the error 'Must declare the scalar variable "@ACK"'.
推荐答案
摆脱
if (!string.IsNullOrEmpty(TextBox6.Text))
- 你必须有参数,如果它是NULL你必须把它设置为DBNull.Value
-- you must have the parameter, if it's NULL you must set it to DBNull.Value
这篇关于必须声明标量变量“@ ACK”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文