简体   繁体   中英

Can I use the Access Database Engine 2010 from a C++ program built with Visual Studio 2017?

Is there a way to get DAO to connect with Access Database Engine 2010 in an MFC C++ application built with Visual Studio 2017? I'm working on a legacy application that needs to read Access 97 MDB databases and from what I've read online, support for these was dropped in Access Database Engine 2016. I have both versions of the database engine installed on my PC, but the application built with VS 2017 only seems to connect to the 2016 version. When the application was built with VS 2015 it worked fine. Is there a way to make my application use the 2010 version instead so I can open these old databases? (Going back to VS 2015 is not an option)

Every copy of windows - going back to windows 98SE has a copy of the JET (mdb) Access database engine installed. So if you looking to only read and use mdb files - then the built in default copy of JET data engine should work. It is possible that later editions of windows have a newer version of JET and thus can't read a97 mdb files, but I believe the default engine installed on windows can read such files.

So you don't need to, and should not have to install a copy of the data engine. You can use either .NET ODBC provider, or you can use the .net oleDB provider. Both of these providers should be able to consume and use and open mdb files without any additonal software being installed on your part.

You DO however have to ensure that your project is set (forced) to use x86 compile, and do NOT deploy with "any CPU" or of course x64 bits, since as such, you can't use + consume x32 bit.dll's and software if your project is running as x64 bits.

Edit: so to be sure that you using this older and pre-installed data engine? Simply don't use "ACE" in your connection string. The built in .net (Visual Studio) connection builder WILL let you set/choose the "JET" (older) mdb data engine as opposed to the newer (ACE) accDB data engine.

You see this option here:

在此处输入图像描述

And then:

在此处输入图像描述

So from above, if you choose JET as opposed to ACE? Then you using the 20 year copy of JET that is installed by defualt on every copy of windows since windows 98SE. And this choice should allow you to open a97 mdb files, and the BONUS feature is that you don't need to install the ACE data engine, nor connectivity component packs either - it is pre-installed on windows.

if you going to use accDB format? Then you MUST install ACE. However, JET is and should already be installed.

Edit: I see that you were talking about c++ and NOT c#/vb.net. However the above advice still holds. It will thus still be your choice to use ODBC or oleDB in your code - and as noted both should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM