Reputation: 27
I have an Excel sheet with no column names.
I want to update values of individual cells without using a WHERE condition. For example Cell A1 is empty and I would like to insert string value "Foo" into it. Below is what I have tried but its not working.
System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand();
string sql = null;
var myConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\\Users\\MAX\\Desktop\\test.xls';Extended Properties=Excel 8.0;");
myConnection.Open();
myCommand.Connection = myConnection;
sql = "UPDATE Sheet1 SET A1='Foo'";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
myConnection.Close();
Upvotes: 1
Views: 206
Reputation: 18137
You need something like this.
sql = "UPDATE [Sheet1$A1:A1] SET F1='FOO'";
Here is another question, which you can use if it is not clear enough.
Upvotes: 1