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

StackOverflow https://stackoverflow.com/questions/16610940

  •  29-05-2022
  •  | 
  •  

Question

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.

Était-ce utile?

La 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.

Autres conseils

string connectionString = "Provider=Microsoft.Jet.OleDb.4.0;Extended Properties=Excel 12.0 Xml;HDR=YES; Data Source=C:\Users\q\Desktop\Ug\Test.xlsx";

As said here, probably you have the 64-bit office installed which doesn't have the 32-bit compnents installed (links are provided there). You may also have to biuld your project targetint x86 platform.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top