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.
Who is Participating?
Dim oledbexcelConnection As OleDbConnection = New OleDbConnection("Insert your connection string here")
And to find the right connection string, have a look here:
lunch_is_4_wimpsAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.