Connect with Expertise | Find Experts, Get Answers, Share Insights

Update statement for whole table

msjonathan's Avatar  
Join Date: Dec 2009
Location: Belgium
Posts: 22
#1: Jan 28 '10
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.

Expand|Select|Wrap|Line Numbers
  1.  OleDbConnection con;
  2.  
  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);
  12.  
  13.          OleDbDataAdapter cmd;
  14.          cmd = new OleDbDataAdapter("Update * [" + pWorksheetName + "$]", con);
  15.          con.Open();
  16.          cmd.Update(pData);
  17.          con.Close();
  18.  
Has anyone an idea how to solve this?

Greetz Jonathan

ck9663's Avatar
E
C
 
Join Date: Jun 2007
Posts: 2,206
#2: Jan 28 '10

re: Update statement for whole table


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
tlhintoq's Avatar
E
C
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 3,476
#3: Jan 29 '10

re: Update statement for whole table


This has been reposted to
http://bytes.com/topic/asp-net/answe...cel-file-oledb
Please use the new thread for any responses.
Reply

Tags
excel, sql, update