Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 944
Avinash Avatar asked Aug 22 '13 12:08

Avinash


People also ask

How do you check Microsoft ACE OLEDB 12.0 is installed or not?

Navigate to Start, and enter C:\Windows\System32\odbcad32.exe into the Search programs and files field. When the ODBC Administrator opens, click the Drivers tab and look for Microsoft Excel Driver or Microsoft Access Driver. If these drivers are present, this confirms the existence of 64-bit ACE components.

How do I install OLEDB provider in Excel?

Install the ODBC and OLEDB drivers and components for Office 2010. Secondly, install the drivers on the Windows machine. Double-click the AccessDatabaseEngine.exe file to install it on the target server. Follow the on-screen instructions until the installation is complete.


Video Answer


2 Answers

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
like image 125
Don Vince Avatar answered Oct 01 '22 02:10

Don Vince


You can get around your problem by adding Microsoft Access Database Engine 2010 as prerequisites in Setup project, The following link shows you how to do so, but be careful, if you use VS2017 then the path is different, the path for VS2017 is:

"C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages"

not

"C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages"

Also I noticed that in some cases you have to install "AccessDatabaseEngine.exe" not "AccessDatabaseEngine_X64.exe" on user's machine, even if it is a 64-bit windows!!!

Here is the article including a video showing how to do all this in a step by step:

https://csharp-tutorials1.blogspot.com/2017/12/add-microsoft-access-engine-2010-as.html

Best regards

like image 45
Haider Abbas Avatar answered Oct 03 '22 02:10

Haider Abbas