c#简单更新查询不工作
本文关键字:工作 查询 更新 简单 | 更新日期: 2023-09-27 18:13:38
SqlConnection conn = new SqlConnection(@"Data Source=SAI'SQLEXPRESS;Initial Catalog=testing;Integrated Security=True;Pooling=False");
conn.Open();
SqlCommand command = new SqlCommand();
string test = "UPDATE attend Year='2014' WHERE Id = '2'";
command = new SqlCommand(test, conn);
command.ExecuteNonQuery();
conn.Close();
Year和id都是varchar
。错误:
'Year'附近语法错误。
应该是:
UPDATE attend SET Year='2014' WHERE Id = '2'