Reading an Excel file in C#

"Meguiar, Richie" <[email protected]> Fri, 13 Apr 2007 14:32:03 -0600
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <[email protected]>
I'm trying to read in an excel file with no luck..  Here is the code I'm
using to setup the connection and commandtext..  Any ideas what I'm
doing wrong?

 

 

string ConnectionString = @"Driver={Microsoft Excel Driver
(*.xls)};DBQ=c:\test.xls";

Microsoft.Data.Odbc.OdbcConnection conn = new
Microsoft.Data.Odbc.OdbcConnection(ConnectionString);

conn.Open(); 

Microsoft.Data.Odbc.OdbcCommand cmd = new
Microsoft.Data.Odbc.OdbcCommand();

cmd.CommandText = "select * from Sheet1";

 


Confidentiality Notice: The information contained in this message is
intended only for the use of the addressee, and may be confidential
and/or privileged. If the reader of this message is not the intended
recipient, or the employee or agent responsible to deliver it to the
intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify the
sender immediately.

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com