Update data in Excel file using OLEDB using C#

Posted: June 1, 2011 in Uncategorized

      System.Data.OleDb.OleDbConnection connection;
       System.Data.OleDb.OleDbCommand command= new System.Data.OleDb.OleDbCommand();
       string sql = null;
       connection= new System.Data.OleDb.OleDbConnection(“provider=Microsoft.Jet.OLEDB.4.0;Data Source=’c:\\book11.xls’;Extended Properties=Excel 8.0;”);
       connection.Open();
       command.Connection = connection;
       sql = “Update [Sheet1$] set name = ‘Xyz’ where id=1”;
       command.CommandText = sql;
       command.ExecuteNonQuery();
       connection.Close();

Advertisements
Comments
  1. Manu says:

    hi mayank,
    good one example..

    thanks for the help.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s