The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. error for excel

5.6k Views Asked by At

enter image description here

i use windows 7 home basic 64-bit and microsoft excel starter 2010 and i want to read an excel file but when i debug my code, i take this error: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. my code is the followings:

protected void Page_Load(object sender, EventArgs e)
{
    GridView1.DataSource=getirExcel();
    GridView1.DataBind();
}
DataTable getirExcel()
{
    string dosya_adres = @"C:\Users\Erdi\Downloads\DBE_BAKIM_FORMU.xlsx";
    OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dosya_adres + ";Extended Properties=Excel 12.0");
    baglanti.Open();
    string query = "select * from [Sheet1$A1:D20]";
    OleDbDataAdapter oAdp = new OleDbDataAdapter(query, baglanti);
    DataTable dt = new DataTable();
    oAdp.Fill(dt);
    return dt;
}

i have tried Microsoft.JET.OLEDB.4.0 but it does not work for 64-bit according to forums. do you know any alternative provider?

thanks in advance..

1

There are 1 best solutions below

0
On

You need to install the database engine here: http://www.microsoft.com/en-us/download/details.aspx?id=13255