By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,419 Members | 1,584 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,419 IT Pros & Developers. It's quick & easy.

Update statement for whole table

P: 24
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:

I change some things in the DataTable and then I want to write to a copy of the first excel file.

Expand|Select|Wrap|Line Numbers
  1.  OleDbConnection con;
  3.          if (isOpenXMLFormat)
  4.             //read a 2007 file  
  5.             ConnectionsString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
  6.                  pFileName + ";Extended Properties=\"Excel 8.0;HDR=YES;\"";
  7.          else
  8.             //read a 97-2003 file  
  9.             ConnectionsString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
  10.                 pFileName + ";Extended Properties=Excel 8.0;";
  11.          con = new OleDbConnection(ConnectionsString);
  13.          OleDbDataAdapter cmd;
  14.          cmd = new OleDbDataAdapter("Update * [" + pWorksheetName + "$]", con);
  15.          con.Open();
  16.          cmd.Update(pData);
  17.          con.Close();
Has anyone an idea how to solve this?

Greetz Jonathan
Jan 28 '10 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 2,878
This is more of an excel question than a SQL Server question. Try posting it in ASP.NET, since it uses the same technology.

Happy Coding!!!

~~ CK
Jan 28 '10 #2

Expert 2.5K+
P: 3,525
This has been reposted to
Please use the new thread for any responses.
Jan 29 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.