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

时光怂恿深爱的人放手 提交于 2019-11-30 09:48:49

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

If you want use AccessDatabaseEngine 64 and IIS 64 bit (example windows 2012 64bit), then follow

  1. You must add role asp.net 4.0, .net 4.0 on IIS

  2. Open IIS Manager

  3. Open your site's application pool's advenced setting

  4. Enable 32-bit Applications set to False (must do this, or not iis set to 32 bit engine)

  5. if your site use .net 4.0, then .NET Framework version set to exactly version

6. [this is keypoint!!!] Managed Pipeline Mode set to "Classic"

good luck :)

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

To use this lib you need installed Office on computer. If have one you can simply add lib in typical way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!