在 x64 操作系统下使用 C# 查询 Jet 数据库/Excel 文件 [英] Querying Jet Databases/Excel files with C# under x64 OS

查看:22
本文介绍了在 x64 操作系统下使用 C# 查询 Jet 数据库/Excel 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我了解到用于查询数据源(如 Microsoft Access MDB 文件和 Excel 电子表格)的 Microsoft.Jet.OLEDB.4.0 数据提供程序在 Windows 64 位操作系统下不起作用.

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.

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

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.

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

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).

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

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

x64 下抛出的示例:

Example Exeption Thrown Under 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 options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)

************** 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)

推荐答案

我在自己最近的研究中看到的一切都证实了您所看到的 - 根本没有 64 位 Jet 驱动程序.另外,我在 THIS 线程似乎证实 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.

这篇关于在 x64 操作系统下使用 C# 查询 Jet 数据库/Excel 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆