Link to home
Start Free TrialLog in
Avatar of TALJr
TALJr

asked on

Fix for Exception when connecting to an Excel .xls file using .NET.?

I am having difficulty connecting to an Excel  .xls file (used as a DB source) in .NET.

When I try to connect using .NET and the following connection string I get an exception:

string strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = "C:\data.xls; Extended Properties=""Excel 8.0; HDR=YES; """

The exception says that the Microsoft.Jet.OLDDB.4.0 provider is not registered.

I am using VS 2005,  and Excel from Microsoft Office 2003.

Does anyone have a fix for this or an alternative solution?

 I need to input the data in an Excel file, make changes and then output to an SQL Server 2005 table.

Thanks,
TALJr
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

I assume that you are using it like this:
OleDbConnection con = new OleDbConnection(strConn);


Avatar of TALJr
TALJr

ASKER

Here's the code:
OleDbConnection Conn = new OleDbConnection;
Conn.ConnectionString = strConn;
Conn.Open()

Thanks,
TALJr
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial