Updating Excel Rows Using ADO.NET C#
By Mash B
Updating Excel Rows Using ADO.NET c#
Let's modify the name of the first city from Bradenton to Venice in the Excel Spreadsheet using ADO.NET:
string connectionString = @"Provider=Microsoft.Jet.
OLEDB.4.0;Data Source=Book1.xls;Extended
Properties=""Excel 8.0;HDR=YES;""";
DbProviderFactory factory =
DbProviderFactories.GetFactory("System.Data.OleDb");
using (DbConnection connection = factory.CreateConnection())
{
connection.ConnectionString = connectionString;
using (DbCommand command = connection.CreateCommand())
{
command.CommandText = "Update [Cities$] Set City =
\"Venice\" WHERE ID = 1";
connection.Open();
command.ExecuteNonQuery();
}
}
Updating Excel Rows Using ADO.NET C# (1083 Views)