我有一个数据表,我想通过向所有收入低于 30 000 的人额外增加 5000 来更新员工的薪水。
这就是我所做的,甚至认为没有任何错误实际更新没有发生。
也许是建议?
string connectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=lrmg;Integrated Security=True;";
using (sqlConnect = new SqlConnection(connectionString))
{
sqlConnect.Open();
SqlCommand cmd = sqlConnect.CreateCommand();
cmd.CommandText = "UPDATE [Employee] SET [Salary] += 5000 WHERE [Salary] < 30000";
cmd.ExecuteNonQuery();
sqlConnect.Close();
}
labMessage.Text = "The update was processed";
最佳答案
试试 < 30.000
然后值:-)
cmd.CommandText = "UPDATE [Employee] SET [Salary] = [Salary] + 5000 WHERE [Salary] < 30000";
关于c# - 更新一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14237823/