Connection string to xls and xlsx files

Posted on 2012-09-11
Medium Priority
Last Modified: 2012-09-11
This connection string works when I connect to an xls file, but not an xlsx file.

           ConnString = String.Format("provider=Microsoft.Jet.OLEDB.4.0; " & _
                "data source='{0}';" & _
                "Extended Properties=""Excel 8.0; IMEX=1; HDR=No;""", _

How can I make it work for an xlsx file?
Question by:AlHal2
  • 2
  • 2
LVL 20

Expert Comment

by:Rikin Shah
ID: 38385944

Author Comment

ID: 38386151
With this connection string  I got a message

An OLE DB Provider was not specified in the ConnectionString.  An example would be, 'Provider=SQLOLEDB;'.

"Microsoft.ACE.OLEDB.12.0; data source=C:\test.xlsx;Extended Properties="Excel 12.0;";"
LVL 20

Accepted Solution

Rikin Shah earned 800 total points
ID: 38386177
"Provider" is missing!! Also, check with the double quotes in your connection string.

Try this instead-
"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=c:\\exceltest.xls" +
@";Extended Properties=""Excel 12.0;""";

Author Closing Comment

ID: 38386431
Thanks.  I modified it slightly and it worked.

"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Test.xlsx;Extended Properties="Excel 12.0; IMEX=1; HDR=No;""

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Watch the video to know the simple way to remove or recover or reset lost or forgotten passwords of Outlook PST file. With Kernel Outlook Password Recovery tool such operation is very easy to perform. It is a freeware with limitation to use with 500…

621 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