Link to home
Start Free TrialLog in
Avatar of lunch_is_4_wimps
lunch_is_4_wimps

asked on

Help! I'm getting an OleDbException: No error message available, result code: E_FAIL(0x80004005), trying to open an oleDBConnection to an Excel file.


 Dim oledbexcelConnection As OleDbConnection = New OleDbConnection()
 Dim szconnectstring As String =  "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & szfilename & ";" & _
                                                 "Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""

I've tried many different permutations, but still I get the above error, or 'ISAM not found' or something.  This is a connection string that worked fine in ASP, but is now impossible to get working in .NET ADO 2.0.

szfilename = "c:\websites\excel_files\myexcelfile.xls"

I'm desperate.  500 pts for whomever can get this so the connection opens and retrieves the rows in the 'new_range' range name.
ASKER CERTIFIED SOLUTION
Avatar of maidinhtai
maidinhtai

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
Avatar of lunch_is_4_wimps
lunch_is_4_wimps

ASKER

Hey.  I appreciate you trying but I discovered that's not the problem.  The problem is that, while in ASP M$ was somewhat forgiving in use of 'Extended Properties', this is no longer the case.  You now need to have a double-quote on each side of the ExtendedProperties portion of the string.  WhatI had to do was add a " in the right spot...namely:

Dim szconnectstring As String =  "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & szfilename & ";""Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""

The above connection string for Excel 8.0 will work.  What you provided was a general rule.  But heck, since you were nice enough to respond at all!, I award you the points. ;-)

Thanks for responding in a timely manner.  See how many points a person can acquire just for being nice? :)
Nice guy! :D