我正在尝试根据用户的输入升级数据库,但它不起作用......
我正在使用这个:
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strcon);
SqlCommand cmd = new SqlCommand();
SqlCommand ncmd = new SqlCommand("Update Utenti Set Nome = @vnome where [Indirizzo E-Mail]=@vem", con);
ncmd.Parameters.AddWithValue("@vem", Session["[Indirizzo E-Mail]"].ToString());
ncmd.Parameters.AddWithValue("@vnome", TextBox2.Text);
ncmd.Connection = con;
con.Open();
ncmd.ExecuteNonQuery();
con.Close();
Label2.Text = "Dati aggiornati con successo!";
Response.Redirect("~/ModificaDati.aspx");
}
当我单击按钮时,它显示 Label2 文本,但在数据库中“Nome”没有改变,为什么?谢谢之前的回答^^