Hi,
I'm trying to update an excel file with using c# oledb way.
I have excel files more than one. One of then hasn't any problem and i can update like what i want.
But other excel files i have some missmatch column.
I want to update cell like a string but it's type is number ( on Excel ), So i'm getting mismatch error for this.
I look at the forums and saw IMEX=1 can solve the problem.
But when i add IMEX=1 i got this error :
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: Operation must use an updateable query.
Here is my code block :
string excel = String.Format("UPDATE {0} SET F1='{1}'", shtsrg,exres);
string exceltwo = String.Format("UPDATE {0} SET F1='{1}'", shtsrgtwo, exrestwo);
OleDbConnection baglans = new OleDbConnection();
baglans.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + yeniDosya + "; Extended Properties = 'Excel 8.0; HDR=NO'";
baglans.Open();
OleDbCommand cmds = new OleDbCommand(excel, baglans);
cmds.ExecuteNonQuery();
baglans.Close();
OleDbConnection baglanstwo= new OleDbConnection();
baglanstwo.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + yeniDosya + "; Extended Properties = 'Excel 8.0; HDR=NO; IMEX=1'";
baglanstwo.Open();
OleDbCommand cmdstwo = new OleDbCommand(exceltwo, baglanstwo);
cmdstwo.ExecuteNonQuery();
baglanstwo.Close();
I used 2 connection for just i want to see where is the problem. I'm updating 2 columns. With 1. connection i haven't any problem. I have a problem with second one.
Is there anyway for change excel's cell data type without Imex ? Or anything solve Updateable query error ?
What I have tried:
Imex=1 is not solving my problem and gives another one.