Reputation: 23
I'm developing a plugin for AutoCAD and need to read data from Microsoft Access. But I always got an Exception:
the 'microsoft.xxx.oledb.x.0' provider is not registered on the local machine
Windows 10 1803 + Office 365 + Microsoft Access Database Engine 2010 + Autodesk AutoCAD 2015
var path = "path_to_mdb_file");
var connectionString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data source={path}";
using (var connection = new OleDbConnection(connectionString))
{
connection.Open();
...
test passed
var path = "path_to_mdb_file");
var connectionString = $"Provider=Microsoft.ACE.OLEDB.12.0;Data source={path}";
using (var connection = new OleDbConnection(connectionString))
{
connection.Open();
...
exception: the 'microsoft.ace.oledb.12.0' provider is not registered on the local machine
var path = "path_to_mdb_file");
var connectionString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data source={path}";
using (var connection = new OleDbConnection(connectionString))
{
connection.Open();
...
exception: the 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine
var path = "path_to_mdb_file");
var connectionString = $"Provider=Microsoft.ACE.OLEDB.12.0;Data source={path}";
using (var connection = new OleDbConnection(connectionString))
{
connection.Open();
...
everything is ok.
Same code, different result, Why?
Upvotes: 2
Views: 6682
Reputation: 155280
*.mdb
version:
*.mdb
file in a hex editor and verifying the first 32 bytes of file contains the ASCII string "Standard Jet DB
".
Standard ACE DB
" then you have an ACE database (*.accdb
), not a JET Red (*.mdb
) file that's just been renamed.0x14
:
0x00
then you have a JET 3.0 database (Access 95, Access 97).0x01
then you have a JET 4.0 database (Access 2000, 2002, 2003).To work with JET 4.0 databases (not JET 3.0 databases!) with OLE-DB (this answer is not concerned with ODBC!) you can use either Microsoft.JET.OLEDB.4.0
or Microsoft.ACE.OLEDB.12.0
(or later).
Microsoft.ACE.OLEDB.*
provider support JET 4.0 databases:
Microsoft.ACE.OLEDB.12.0
(Access 2007)
Microsoft.ACE.OLEDB.14.0
(Access 2010)
Microsoft.ACE.OLEDB.15.0
(Access 2013)
Microsoft.ACE.OLEDB.16.0
(Access 2016, Access 2019)
Important note: The Microsoft.Jet.OLEDB.4.0
provider is only available for 32-bit (x86) programs.
All versions of the Microsoft.ACE.OLEDB.*
provider are available in both 32-bit and 64-bit versions and can be installed side-by-side.
Microsoft.ACE.OLEDB.15.0
provider - but note that it also registers version 15 as an alias for Microsoft.ACE.OLEDB.12.0
. This is the "fake" version I mentioned above.
Microsoft.ACE.OLEDB.12.0
in embedded connection-strings, which meant that they'd be broken if the software was run on a computer that had v14, v15, or v16 and didn't have v12 installed.
Microsoft.JET.OLEDB.4.0
or Microsoft.ACE.OLEDB.12.0
.
Microsoft.JET.OLEDB.4.0
provider will be installed by-default on most Windows installations without needing Office or Access installed.Microsoft.ACE.OLEDB.12.0
is installed by default in Windows.Microsoft.ACE.OLEDB.12.0
or later, provided you installed the 64-bit provider from the Access Database Engine installer.
Microsoft.ACE.OLEDB.16.0
).Upvotes: 5