我想从我的网页中的 FreeTextBox 更新数据库。但我不能这样做,我的代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
string page1 = DropDownList1.SelectedValue;
SqlConnection con = new SqlConnection(
"Data Source=NODE5-PC;Initial Catalog=hans;User ID=sa;Password=123");
con.Open();
string sql = "UPDATE PageMaster SET Content=@FreeText WHERE Page=@Page1 ";
SqlCommand ucmd = new SqlCommand(sql, con);
ucmd.Parameters.AddWithValue("@FreeText", FreeText.Text);
ucmd.ExecuteNonQuery();
con.Close();
FreeText.Text = "";
}
发生的错误是:
必须声明标量变量“@Page1”。