Search code examples
c#excelms-accessjet

Import Excel 2013 to vs, Microsoft ACE.OLEDB.12.0 is not registered on the local Machine


Creating a form application in vs 2012. I have office 2013 installed, win 8 64 bit. I get the above error for the below piece of code.

public void SetConnection(string text1, string text2, string text3, string text4, string text5, string text6, string text7)
    {
        connectionString1 = "Initial Catalog=test; Data Source=work\\sqlexpress";
        connectionString = "Data Source='c:\\Users\\test1.xlsx';Extended Properties=Excel 12.0 Xml;Readonly=False;";
        database = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" + connectionString);
        database.Open();
        database1 = new OleDbConnection("Provider=SQLOLEDB.1;" + connectionString1);
        database1.Open();
    }

I tried using jet drivers but would not work, so i turned to ace. First i got "Cannot find installable ISAM"; so installed AccessDatabaseEngine_x64 which leads me to this error. I then changed my build to x86 and same errors. So i'm out of options. I did try previous versions of AccessDatabaseEngine from 2007 and 2010 but no luck, any suggestions.


Solution

  • database = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\\Users\\test.xls';Extended Properties= \"Excel 8.0;HDR=Yes;IMEX=1\";");
    

    The above connection string works using jet although i have to leave the excel file open for the time being as i get "could not decrypt file" error otherwise. I also had to save the file as a 97-03 excel xls file.