Search code examples
c#.netlinq-to-excel

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. c#


I am trying to use linq_to_excel

http://www.softinterface.com/DL/DL_UserData_Proc.ASP

This is my code:

var data = new LinqToExcel.ExcelQueryFactory();
            data.FileName= @"FRM_DTA.xlsx";
            data.AddMapping<ExcelFileDefinition>(x => x.FARM_ID, "FRM_ID");
            data.AddMapping<ExcelFileDefinition>(x => x.FARM_OWNER, "FRM_OWNER");
            data.AddMapping<ExcelFileDefinition>(x => x.FARM_AREA_ID, "FRM_AREA_ID");
            data.AddMapping<ExcelFileDefinition>(x => x.FARM_EMARA_ID, "FRM_EMARA_ID");
            data.AddMapping<ExcelFileDefinition>(x => x.FARM_REGION_ID, "FRM_REGION_ID");
            data.AddMapping<ExcelFileDefinition>(x => x.FARM_NUMBER, "farmNumber");
            data.AddMapping<ExcelFileDefinition>(x => x.RECEIVING_CENTER_ID, "RecievingCentreID");
            var result = from x in data.Worksheet<ExcelFileDefinition>()
                         select x;
            (foreach(var row in result){
                Console.WriteLine(row.FARM_ID);
            }

when I run it, I got this exception:

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

Help please

What I have tried

I found this question Microsoft.ACE.OLEDB.12.0 provider is not registered and I changed my platform target from any cpu to x86 but still have the problem


Solution

  • Download and install Microsoft Access Database Engine 2010 Redistributable