Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 3rd, 2004, 02:20 AM
Registered User
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update Excel File Using ADO .Net

The following code is not updating the excel file passed in the FileName parameter. No exceptions are being thrown.

public void UpdateExcelFile(string SomeFile)
{

OleDbConnection Connection = new OleDbConnection();

try{
OleDbCommand Command = new OleDbCommand();

string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + SomeFile + ";Extended Properties=Excel 8.0;";

Connection.ConnectionString = ConnectionString;
Connection.Open();

string MyCommandText = "UPDATE [Sheet1$A1:A1] SET F1 = 'SomethingNew'";

Command.CommandText = MyCommandText;

Command.Connection = Connection;

Command.ExecuteNonQuery();
}
catch(Exception ex)
{}
finally
{ Connection.Close() }
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Get data from Excel file using ADO.NET lam_lvl ADO.NET 7 February 27th, 2014 05:19 AM
ADO.NET and Excel Theone84 ADO.NET 0 July 7th, 2008 05:20 AM
Problems importing Excel into ADO.Net recordset AshleyC ADO.NET 0 February 22nd, 2005 05:56 AM
Referencing a closed excel file using ADO. cunninb Excel VBA 0 January 10th, 2005 12:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.