Hej hej,
I am trying to write an SQL update statement where I want to update an Excel file. But my Update statement is not valid, I have to use set .... But I do not know the columns in the Excel file, those can be different each time.
First I read an excel file with this code: http://codehill.com/2009/01/reading-...s-using-oledb/
I change some things in the DataTable and then I want to write to a copy of the first excel file.
Has anyone an idea how to solve this?
Greetz Jonathan
I am trying to write an SQL update statement where I want to update an Excel file. But my Update statement is not valid, I have to use set .... But I do not know the columns in the Excel file, those can be different each time.
First I read an excel file with this code: http://codehill.com/2009/01/reading-...s-using-oledb/
I change some things in the DataTable and then I want to write to a copy of the first excel file.
Code:
OleDbConnection con;
if (isOpenXMLFormat)
//read a 2007 file
ConnectionsString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
pFileName + ";Extended Properties=\"Excel 8.0;HDR=YES;\"";
else
//read a 97-2003 file
ConnectionsString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
pFileName + ";Extended Properties=Excel 8.0;";
con = new OleDbConnection(ConnectionsString);
OleDbDataAdapter cmd;
cmd = new OleDbDataAdapter("Update * [" + pWorksheetName + "$]", con);
con.Open();
cmd.Update(pData);
con.Close();
Greetz Jonathan
Comment