Connection string to xls and xlsx files

Posted on 2012-09-11
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
    LVL 19

    Expert Comment

    by:Rikin Shah

    Author Comment

    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 19

    Accepted Solution

    "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

    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

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    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

    17 Experts available now in Live!

    Get 1:1 Help Now