Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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
3
Medium Priority
?
2,621 Views
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.
0
Comment
Question by:lunch_is_4_wimps
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
maidinhtai earned 1500 total points
ID: 16608368
Dim oledbexcelConnection As OleDbConnection = New OleDbConnection("Insert your connection string here")
And to find the right connection string, have a look here:http://www.connectionstrings.com/
0
 

Author Comment

by:lunch_is_4_wimps
ID: 16608619
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? :)
0
 
LVL 3

Expert Comment

by:maidinhtai
ID: 16608680
Nice guy! :D
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

564 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