更新根本不起作用,行保持不变。我得到没有错误。有谁知道为什么它不起作用? 我想首先知道问题的原因,但如果您有任何想法,关于如何改进我的代码的建议,我们会受到欢迎。sql简单的更新语句不起作用
private void button2_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\C#\InsertDeleteUpdate-Login\InsertDeleteUpdate-Login\Database1.mdf;Integrated Security=True"))
using (SqlCommand cmd = new SqlCommand("UPDATE info SET [email protected] WHERE [email protected] AND [email protected]",conn))
{
conn.Open();
cmd.Parameters.AddWithValue("@Password", textBox4.Text);
cmd.Parameters.AddWithValue("@Id", textBox3.Text);
cmd.Parameters.AddWithValue("@Password1", textBox2.Text);
}
}
你需要执行查询 – user1666620
使用:'cmd.ExecuteNonQuery()' – Stefan
你缺少'cmd.ExecuteNonQuery()' – TFrost