Saturday, March 28, 2015

How do I write to specific cells in Excel? ... C#, OleDb

SET is not used in an INSERT statement. Try this:



string sql = "Insert into [" + stSheetName + "$A2:B2] VALUES('5','e')";



You could also use an UPDATE statement to update a specific cell:



string sql = "UPDATE [" + stSheetName + "$A2:A2] SET F1=5";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();

sql = "UPDATE [" + stSheetName + "$B2:B2] SET F1=e";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();



Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.



No comments:

Post a Comment