How to fix "Microsoft.Jet.OLEDB.4.0 provider cannot be used in Visual Studio because it is 32-bit only" in Visual Studio 2022?

huangapple go评论61阅读模式
英文:

How to fix "Microsoft.Jet.OLEDB.4.0 provider cannot be used in Visual Studio because it is 32-bit only" in Visual Studio 2022?

问题

我需要将数据库添加到我的GUI,每次测试连接时都会出现以下错误,并且另一个问题是我无法将Microsoft Access数据库导入Visual Studio:

How to fix "Microsoft.Jet.OLEDB.4.0 provider cannot be used in Visual Studio because it is 32-bit only" in Visual Studio 2022?

我已经修复了“Microsoft Jet Oledb Provider未在本地机器上注册”的错误,我尝试测试连接并且成功了,但是每当我尝试导入MS-Access数据库时,它不会出现。现在我有这个问题。

英文:

I need to add a database to my GUI and this is the error that appears whenever I test the connection, and the other problem is that I can't import Microsoft Access database to Visual Studio:

How to fix "Microsoft.Jet.OLEDB.4.0 provider cannot be used in Visual Studio because it is 32-bit only" in Visual Studio 2022?

I already fixed the error of "Microsoft Jet Oledb Provider Not Registered On Local Machine" and I tried to test the connection and its successful but whenever I tried to import the MS-Access database, it doesn't appear. Now I have this problem.

答案1

得分: 1

Dave S.在他们的评论中说的是真的,但我认为在这种情况下是因为Visual Studio 2022是64位。这是Visual Studio的第一个64位版本,而不是32位。

错误消息“sort of”指出了它的措辞方式:

不能在_Visual Studio_中使用Microsoft.Jet.OLEDB.4.0提供程序,因为它只支持32位。

请注意,它明确指出了“Visual Studio”。

如果你去看一下链接,在错误消息中说明:

如果您使用Visual Studio连接到OLEDB或ODBC数据提供程序连接数据库,您需要知道,Visual Studio 2022之前的版本都是32位进程。这意味着Visual Studio中的某些数据工具只能连接到32位数据提供程序的OLEDB或ODBC数据库。这包括Microsoft Access 32位OLEDB数据提供程序以及其他第三方32位提供程序。

如果您使用Visual Studio 2022连接到数据库,您需要知道Visual Studio 2022是64位进程。这意味着Visual Studio中的某些数据工具将无法连接到32位数据提供程序的OLEDB或ODBC数据库。

如果您需要维护连接到OLEDB或ODBC数据库的32位应用程序,您仍然可以使用Visual Studio 2022构建和运行该应用程序。但是,如果您需要使用Visual Studio Data Tools中的任何工具,例如Server Explorer、Data Source Wizard或DataSet Designer,您需要使用Visual Studio的早期版本,该版本仍然是32位进程。最后一个32位进程的Visual Studio版本是Visual Studio 2019。

从外观上看,你正在使用“数据源向导”(至少我这么猜测),根据这个页面的信息,你在Visual Studio 2022中可能无法执行这项操作,因为它不是32位。

英文:

While what Dave S. said in their comment is true, I think in this case it is because Visual Studio 2022 is 64-bit. It is the first version of Visual Studio that is 64-bit rather than 32-bit.

The error message sort of indicates that with the way it is worded:

> The Microsoft.Jet.OLEDB.4.0 provider cannot be used in Visual Studio because it is 32-bit only.

Note how is specifically says Visual Studio.

If you go to the link that is in that error message, it states:

> If you're using Visual Studio to connect to databases using OLEDB or ODBC data providers, you will need to be aware that versions of Visual Studio prior to Visual Studio 2022 are all 32-bit processes. This means some of the data tools in Visual Studio will only be able to connect to OLEDB or ODBC databases using 32-bit data providers. This includes the Microsoft Access 32-bit OLEDB data provider as well as other third-party 32-bit providers.
>
> If you're using Visual Studio 2022 to connect to databases, you will need to be aware that Visual Studio 2022 is a 64-bit process. This means some of the data tools in Visual Studio will not be able to connect to OLEDB or ODBC databases using 32-bit data providers.
>
> If you need to maintain 32-bit applications that connect to OLEDB or ODBC databases, you will still be able to build and run the application with Visual Studio 2022. However, if you need to use any of the Visual Studio Data Tools such as Server Explorer, Data Source Wizard, or the DataSet Designer, you will need to use an earlier version of Visual Studio that is still a 32-bit process. The last version of Visual Studio that was a 32-bit process was Visual Studio 2019.

By the looks of it, you are using the "Data Source Wizard" (that is my guess at least), which according to this page, you won't be able to do in Visual Studio 2022 since it is not 32-bit.

答案2

得分: 0

以下是您要翻译的内容:

"在大多数情况下,解决方案是使用Access数据库引擎的x64位版本。

旧的JET数据引擎仅限于使用.mdb文件,并且这个选择仅限于x32位。

而新的ACE数据引擎可以打开.mdb和accDB文件。
它也有x32位和x64位版本。

无论您是否使用VS 2022(x64位)还是之前的x32位版本?

您仍然可以使用x32位的JET版本,也可以使用x32位的ACE版本。

您甚至可以在vs2022中使用JET引擎。

然而,这意味着某些数据向导将无法工作(例如创建GridView的向导)。

所以,您仍然可以在代码中使用JET或ACE,即使在vs2022中也可以使用JET或ACE。

首先:

在数据连接中,(我假设我们是从设置中进行操作,而不是使用GridView的向导)。

然后,您会看到这个:

How to fix "Microsoft.Jet.OLEDB.4.0 provider cannot be used in Visual Studio because it is 32-bit only" in Visual Studio 2022?

请不要在这里使用测试连接!!!

然而,要选择JET或ACE,然后点击上面的高级选项:

How to fix "Microsoft.Jet.OLEDB.4.0 provider cannot be used in Visual Studio because it is 32-bit only" in Visual Studio 2022?

请注意,我们可以选择JET(旧的x32位)或ACE(新的,有x32位和x64位版本)。

好的,如果您实际上看到ACE选项,那意味着您已安装了x32位驱动程序。

这里还有一个非常重要的步骤:

由于您很可能想要使用x32位的Access(ACE),那么您必须强制将项目设置为以x32位(x86)运行。

就是这个设置:

How to fix "Microsoft.Jet.OLEDB.4.0 provider cannot be used in Visual Studio because it is 32-bit only" in Visual Studio 2022?

所以,总结一下:

是的,即使在vs2022中,您仍然可以使用JET,您仍然可以使用x32位版本的JET。这将意味着仅支持mdb文件,而不支持accDB文件。

是的,即使在vs2022中,您仍然可以使用ACE,您仍然可以使用x32位版本的ACE。这将意味着您可以打开mdb和accdb文件。

如果您希望在vs2022中使向导正常工作,那么您可以并且应该安装ACE的x64位版本,因为这将意味着:

测试连接现在将正常工作,并且如果您使用和连接到accDB文件的话,向导也应该正常工作。

然而,即使您在不使用测试连接(使用JET或x32位ACE时)时,运行项目,并且假设您已将项目强制设置为x32位,那么您的JET或ACE代码和使用将正常工作,即使使用x32位的JET或ACE也是如此。唯一无法工作的是测试连接,正如前面提到的,还有一些向导。

无论如何,任何打开和使用数据库的代码都将正常工作,即使在使用vs2022时也是如此。

总的来说,因为我不常使用向导,但我绝对会使用上面的屏幕截图所示的连接向导和设置,所以我可以在vs2022中使用Access数据库而几乎没有问题。

因为我仍然在进行大量的Access开发,所以我还没有将我的Access版本升级为x64位版本,但这将是最佳解决方案,因为那样甚至在vs2022中测试连接和向导都会正常工作。

所以,暂时跳过上面屏幕截图中的测试连接,如果您不需要GridView等数据向导,那么您可以在vs2022中正常工作,并且在运行项目时,连接将正常工作。"

英文:

Well, the soluiton in most cases then is to use the x64 bit version of the Access data base engine.

the older JET data engine is limited to using .mdb files. And this choice is ONLY x32 bits

While the newer ACE data engine can open both .mdb and accDB files?
It is ALSO available in x32 bits, or x64 bits.

Regardless of you using VS 2022 (x64 bits), or previous versions that are x32 bits?

You can STILL USE the x32 bit verison of JET, and you can STILL USE the x32 bit verison of ACE.

And you cna STILL USE that JET engine in vs2022.

However, this will mean that some of the data wizards will not work (such as ones to create a gridview).

So, you can STILL however in code use JET or ACE, and you CAN STILL use JET or ACE EVEN with vs2022.

So, first up:

in the data connection, (and I assume we doing this from settings, NOT a wizard for say a gridview).

Then you see this:

How to fix "Microsoft.Jet.OLEDB.4.0 provider cannot be used in Visual Studio because it is 32-bit only" in Visual Studio 2022?

DO NOT use test connection here!!!

However, to select JET or ACE, then click on advanced in above:

How to fix "Microsoft.Jet.OLEDB.4.0 provider cannot be used in Visual Studio because it is 32-bit only" in Visual Studio 2022?

So, note how we can choose JET (older x32 only), or ACE. (newer, comes in both x32 and x64).

Ok, so if you actually see the ACE choice, then that means you have a x32 driver installed.

ONE MORE HUGE important step here:

Since you may well be wnating to use access x32 (ACE), then you MUST force your project to run as x32 (x86).

That is this setting:

How to fix "Microsoft.Jet.OLEDB.4.0 provider cannot be used in Visual Studio because it is 32-bit only" in Visual Studio 2022?

So, in summary:

Yes, even with vs2022, you CAN use JET and you CAN use the x32 bit verison of JET. This will mean ONLY mdb files, and not accDB files.

yes, even with vs2022, you CAN use ACE and you CAN use the x32 bit version of ACE. This will mean that you can open both mdb and accdb files.

And if you want the wizards to work in vs2022, then you CAN and SHOULD install ACE x64 bits, as that will mean:

The test conneciton will now work, and the wizards should also work assuming you using and connecting to a accDB file.

however, even if you DO NOT use test connection (when using JET or x32 ACE), when you run the project, and ASSUMING you forced the project to x32 bits, then your code and use of JET OR ACE will work, will work EVEN if you using x32 JET or ACE. The only thing that will not work is the test connection, and as noted, then some of the wizards.

however, any code that opens and uses the database will work, and will work even when using vs2022.

All in all, since I don't use the wizards much, but I MOST certainly do use the conneciton wizard and setup as above screen shots show, then I am able to use access databases without any much issues - even in vs2022.

Because I am still doing a lot of access development, then I have NOT upgraded my version of Access to x64 bit version, but that would be the best solution here, since then even the wizards and connecting testing in vs2022 will now work.

So, for now, SKIP the test connection in above screen shot, and if you not requiring the data wizards for a grid view etc., then you can quite much work in vs2022 without issues, and WHEN you run the project, the connections will work.

huangapple
  • 本文由 发表于 2023年6月8日 00:21:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76425344.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定