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

Posted on 2006-05-04
Last Modified: 2008-02-20

 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.
Question by:lunch_is_4_wimps
    LVL 3

    Accepted Solution

    Dim oledbexcelConnection As OleDbConnection = New OleDbConnection("Insert your connection string here")
    And to find the right connection string, have a look here:

    Author Comment

    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? :)
    LVL 3

    Expert Comment

    Nice guy! :D

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now