在 x64 操作系统下使用 C# 查询 Jet 数据库/Excel 文件

发布于 2024-07-10 04:55:20 字数 1080 浏览 5 评论 0原文

因此,我了解到用于查询 Microsoft Access MDB 文件和 Excel 电子表格等数据源的 Microsoft.Jet.OLEDB.4.0 数据提供程序无法在 Windows 64 位操作系统下运行。

我现在应该使用什么来查询 .NET 3.5 (C#) 应用程序中的这些文件类型,以确保 x86 和 x64 环境中的兼容性? 我已经搜索了 Internet,但似乎无法找到如何处理这种不兼容性的直接答案。

我还尝试过使用 ODBC 提供程序和 MSDASQL 提供程序,但没有成功,因为它们似乎抛出与 Microsoft.JET.OLEDB.4.0 提供程序在 x64 环境中使用时相同的异常(除非我做了一些明显错误的事情)其他两个提供程序,即使它们在我的 Windows XP x86 环境中运行良好)。

我发现有人说我需要使用 %WINDIR%\System32\odbcad32.exe 在 x64 系统中进行 ODBC 连接,但我知道如何利用它。

x64 下抛出的异常示例:

**************** 异常文本 ************** System.InvalidOperationException:“Microsoft.Jet.OLEDB.4.0”提供程序未在本地计算机上注册。 在 System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr,DataSourceWrapper& datasrcWrapper) 在 System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr,OleDbConnection 连接) 在System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions选项,对象池GroupProviderInfo,DbConnectionPool池,DbConnection owningObject)

So I have learned that that the Microsoft.Jet.OLEDB.4.0 data provider for querying data sources like Microsoft Access MDB files and Excel spreadsheets does not work under a Windows 64-bit operating systems.

What I am now supposed to use to query against these file types in .NET 3.5 (C#) applications in order to ensure compatibility in both x86 and x64 environments? I have scoured the Internet and I cannot seem to find a straight answer on how to handle this incompatibility.

I've also tried using an ODBC provider and a MSDASQL provider with no luck as they seem to throw the same exceptions as the Microsoft.JET.OLEDB.4.0 provider does when used in a x64 environment (unless I am doing something flagrantly wrong with these other two providers even though they work fine under in my Windows XP x86 environment).

I’ve found people saying that I need to use %WINDIR%\System32\odbcad32.exe for ODBC connectivity in x64 systems, but I have on idea how to utilize this.

Example Exeption Thrown Under x64:

************** Exception Text **************
System.InvalidOperationException: The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.
at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper)
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

度的依靠╰つ 2024-07-17 04:55:21

这里发生的情况是 x64 程序集试图调用 x86 COM 组件。 x64 应用程序不会在主 x64 注册表中看到 COM 注册,因为它们位于 wow6432node 配置单元中。

最简单的解决方法是使用 x86 目标平台构建应用程序,并让它稍后在 x64 计算机上的 WOW 上运行。 该应用程序将以 32 位运行,并且能够查看其所需的 32 位 COM 对象。

what's happening here is that a x64 assembly is trying to call a x86 COM component. The x64 app won't see the COM registrations in the primary x64 registry,since theyre in the wow6432node hive.

Easiest workaround is to build the application with a x86 target platform and let it run on the WOW later on your x64 machine. The app will run as 32-bit and be able to see the 32-bit COM objects it needs.

梦在夏天 2024-07-17 04:55:21

我在最近的研究中看到的一切都证实了您所看到的——根本不存在 64 位 Jet 驱动程序。 另外,我在 这个线程似乎证实了 64 位 MSDASQL 不会有帮助,因为它实际上只是一个包装器(请参阅 Ricky Wen 于 5 月 8 日发表的最后一篇文章)。 您唯一的选择是通过 32 位代理进行链接,也许是另一个 32 位 SQL 服务器。 我最终可能会自己做这件事,直到我可以将 Jet 数据移动到 SQL。

Everything that I've seen in my own recent research confirms what you are seeing - that there simply isn't a 64-bit Jet driver. Also, I found a post on THIS thread that seems to confirm that the 64-bit MSDASQL won't help as it is really just a wrapper (see the last post, dated May 8 from Ricky Wen). Your only option is to link thru a 32-bit proxy, perhaps another 32-bit SQL server. I may end up doing this myself, until I can move the Jet data to SQL.

格子衫的從容 2024-07-17 04:55:21

现在有适用于 JetSQL 的 64 位 ODBC 驱动程序。 它是 Microsoft Access 数据库引擎 2010 可再发行组件。 我还没有将它用于 OLEDB,但我用它来创建新的 带有 PowerShell 的 Microsoft Access 数据库

There is now a 64 bit ODBC driver for JetSQL. It is the Microsoft Access Database Engine 2010 Redistributable. I have not used it for OLEDB, but I have used it to make new Microsoft Access databases with PowerShell.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文