我有一张包含2张的excel文件,并希望在“数据”中更新一些值。片。 我使用下一个简单的命令:
var myCommand = new OleDbCommand();
var sql = "Update [Sheet2$] set Status = 'New_value' WHERE Building = 12";
var myConnection = new OleDbConnection(connectionString);
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
我收到错误:
System.Data.OleDb.OleDbException : Syntax error in UPDATE statement
我也试过这个:
var sql = "Update [Sheet2$] set Status = 'New_value' WHERE Building = '12'";
但没有成功。这有什么不对?
答案 0 :(得分:2)
转义列status
var sql = "Update [Sheet2$] set [Status] = 'New_value' WHERE Building = 12";