Update statement for whole table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • msjonathan
    New Member
    • Dec 2009
    • 24

    Update statement for whole table

    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.

    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();
    Has anyone an idea how to solve this?

    Greetz Jonathan
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    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

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      This has been reposted to

      Please use the new thread for any responses.

      Comment

      Working...