Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Jun 29, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Connect to Microsoft Excel Using OLE DB

Microsoft documentation says you can connect to Excel 97 or Excel 2000 using the Microsoft.Jet.OLEDB 4.0 provider. If you use the Microsoft ADO Data Control, however, you will have problems. From the property page for the ADO Data Control, choose the Use Connection String radio button and click on the Build button. Then, select the database name, choosing an Excel file as your database. Now, if you click on Test Connection, you get an error message saying the connection failed because the file is in an unrecognized format.

But wait, there's hope! Acknowledge the error message and return to the General tab of the property pages. In the Connection String textbox, add this code to the end of the connection string:
Extended Properties = Excel 8.0;
Your full connection string now looks like this:
Provider=Microsoft.Jet.OLEDB.4.0; Data Source = FileName; Extended Properties=Excel 8.0;
Now if you click on the Build button, then click on the Test Connection button, the connection is successful.
Michael J.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date