Does anyone know how to write to an excel file (.xls) via OLEDB in C#? I’m doing the following:
OleDbCommand dbCmd = new OleDbCommand('CREATE TABLE [test$] (...)', connection); dbCmd.CommandTimeout = mTimeout; results = dbCmd.ExecuteNonQuery();
But I get an OleDbException thrown with message:
‘Cannot modify the design of table ‘test$’. It is in a read-only database.’
My connection seems fine and I can select data fine but I can’t seem to insert data into the excel file, does anyone know how I get read/write access to the excel file via OLEDB?
You need to add
ReadOnly=False;to your connection string