我试图找到它。但我找不到我的答案。所以我决定提出这个问题。我需要你的帮助。C#SqlCommand查询更新
我希望将值添加到表值中,而不会覆盖Debit,Score列。它会增加当前值。
cmd = new SqlCommand("UPDATE Users SET [email protected],
[email protected]
WHERE [email protected]", con);
con.Open();
cmd.Parameters.AddWithValue("@phone", textBox1.Text);
cmd.Parameters.AddWithValue("@debit", textBox2.Text);
cmd.Parameters.AddWithValue("@score", textBox3.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("Амжилттай");
con.Close();
例如:
Table, Phone: 999 | Debit: 1500 | Score: 100 //current <br>
当我从textBox1的= 999,TextBox2中= 500,textBox3 = 50
Table, Phone: 999, Debit: 2000, Score: 150 //updating like that
添加值我知道这样的SQL查询。但我不知道如何编写代码SqlCommand
UPDATE Users
SET Debit = Debit + [user input], Score = Score + [user input]
WHERE = Phone
有什么建议吗?
(对不起,我的英语太可怕了,我希望你们明白我想问)
感谢
你的SqlCommand似乎罚款,这是什么问题? – styx