Reputation: 1547
I have an excel file with 2 sheets and want update some values in 'Data' sheet. I use the next simple commands:
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();
I get error:
System.Data.OleDb.OleDbException : Syntax error in UPDATE statement
I have also tried this:
var sql = "Update [Sheet2$] set Status = 'New_value' WHERE Building = '12'";
but with no success. What is wrong here?
Upvotes: 0
Views: 3975
Reputation: 263893
escape the column status
var sql = "Update [Sheet2$] set [Status] = 'New_value' WHERE Building = 12";
Upvotes: 3