Can we add Reference of 'Microsoft.ACE.Oledb.12.0.dll' to project

Avinash picture Avinash · Aug 22, 2013 · Viewed 43.5k times · Source

I am getting error "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine." on my testing servers. So My Question is :

i) Can i add reference for "'Microsoft.ACE.Oledb.12.0.dll'" to project it self? ii) Is it safe? iii) How to do this?

Every thing is working on my local machine since i have latest version of office install in my machine. As soon as i am deploying my code to testing servers i am getting above error. I might not be able to install Office on testing servers (Due to some reason). So is it possible to put all require dll in project itself and deploy that to testing servers too ?

Thanks in advance.

Answer

Don Vince picture Don Vince · Mar 30, 2014

In order to use "Microsoft.ACE.OLEDB.12" you need to install the "Microsoft Access Database Engine 2010 Redistributable"

The information page for this is here: http://www.microsoft.com/en-us/download/details.aspx?id=13255

And as @user1297578 quite rightly noted the actual download is here: http://www.microsoft.com/en-in/download/confirmation.aspx?id=13255

Once you have installed that, the actual assembly is called ACEOLEDB.DLL, the following command at a Command Prompt will find it for you on your system:

C:\>DIR /s/b c:\ACEOLEDB.DLL
c:\Program Files\Common Files\Microsoft Shared\OFFICE14\ACEOLEDB.DLL

For reference, the following is the error message I received from a program until I installed the above redistributable:

Connection Failed. 
Error from IDataInitialize::GetDataSource
with connectionString=Data Source=C:\MyFileName.mdb;Mode=Share Deny Write;Provider=Microsoft.ACE.OLEDB.12.0;User Id=admin
OLE DB Error Report:
    ErrorRecord:
    Hresult=80040154
    Description: Class not registered
    SQLErrorInfo: No error info available
    Source: Microsoft OLE DB Service Components