使用 Jet 连接到 Access DB

Posted

技术标签:

【中文标题】使用 Jet 连接到 Access DB【英文标题】:Connecting to an Access DB using Jet 【发布时间】:2011-03-15 21:37:44 【问题描述】:

我正在尝试使用 Visual Studio 2008 中的 Jet 连接到 Access 数据库,就像这样 -

dbProvider = "PROVIDER = Microsoft.Jet.OLEDB.4.0;"

然后找到要读取的源文件并打开和关闭它 -

con.Open() con.Close()

但是,我在运行时收到一条错误消息 -

''Microsoft.Jet.OLEDB.4.0' 提供程序未在本地计算机上注册'

我运行的是 Windows 7,msjet40.dll 位于窗口的 SysWOW64 文件夹中。

任何建议都将不胜感激,干杯。

【问题讨论】:

【参考方案1】:

这可能意味着您正在尝试将 32 位应用程序连接到 64 位驱动程序或相反。所以你要么改变你的exe的位数,要么安装相应的访问驱动:Microsoft Access Database Engine 2010 Redistributable

【讨论】:

【参考方案2】:

Jet 在 X64 上无法原生运行。但 SQL Server 可以!~

如何获得 Jet 的 x64 版本? http://blogs.msdn.com/b/psssql/archive/2010/01/21/how-to-get-a-x64-version-of-jet.aspx

我们有很多人询问他们如何才能将 Jet ODBC 驱动程序/OLE DB 提供程序作为 64 位。 Windows 仅提供这些的 32 位版本。答案是 Windows 版本不会是 x64,因为这些项目已被弃用。已弃用是什么意思?以下是 MSDN 上 MDAC/WDAC 路线图的摘录:

Deprecated MDAC/WDAC Components

These components are still supported in the current release of MDAC/WDAC, but they might be removed in future releases. Microsoft recommends, when you develop new applications, that you avoid using these components. Additionally, when you upgrade or modify existing applications, remove any dependency on these components.

这里列出了有关 Jet 数据库引擎的内容:

Microsoft Jet Database Engine 4.0: Starting with version 2.6, MDAC no longer contains Jet components. In other words, MDAC 2.6, 2.7, 2.8, and all future MDAC/WDAC releases do not contain Microsoft Jet, the Microsoft Jet OLE DB Provider, the ODBC Desktop Database Drivers, or Jet Data Access Objects (DAO). The Microsoft Jet Database Engine 4.0 components entered a state of functional deprecation and sustained engineering, and have not received feature level enhancements since becoming a part of Microsoft Windows in Windows 2000.


There is no 64-bit version of the Jet Database Engine, the Jet OLEDB Driver, the Jet ODBC Drivers, or Jet DAO available. This is also documented in KB article 957570. On 64-bit versions of Windows, 32-bit Jet runs under the Windows WOW64 subsystem. For more information on WOW64, see http://msdn.microsoft.com/en-us/library/aa384249(VS.85).aspx. Native 64-bit applications cannot communicate with the 32-bit Jet drivers running in WOW64.


Instead of Microsoft Jet, Microsoft recommends using Microsoft SQL Server Express Edition or Microsoft SQL Server Compact Edition when developing new, non-Microsoft Access applications requiring a relational data store. These new or converted Jet applications can continue to use Jet with the intention of using Microsoft Office 2003 and earlier files (.mdb and .xls) for non-primary data storage. However, for these applications, you should plan to migrate from Jet to the 2007 Office System Driver. You can download the 2007 Office System Driver, which allows you to read from and write to pre-existing files in either Office 2003 (.mdb and .xls) or the Office 2007 (*.accdb, *.xlsm, *.xlsx and *.xlsb) file formats. IMPORTANT Please read the 2007 Office System End User License Agreement for specific usage limitations. 

【讨论】:

这个答案很糟糕而且完全过时了。如果您需要在 64 位环境中处理 Jet 数据,您可以使用 64 位版本的 ACE,Jet 4 的后续版本。

以上是关于使用 Jet 连接到 Access DB的主要内容,如果未能解决你的问题,请参考以下文章

连接到 Jet/ACE 数据库的 Ubuntu Shiny 服务器

Microsoft.Jet.OLEDB.4.0 “找不到提供程序。它可能没有正确安装。”错误

从 C# 连接到 OpenOffice 数据库

是否有一个查询会返回 Microsoft Access 表中的所有列名?

使用 NetBeans 连接到 Java 中的 Access 数据库

使用 DEFAULT 值和 OleDB 时如何终止 SQL 语句?