简体   繁体   中英

Accessing a MS Access database with Qt on Win7 X64

I used to have a Qt application which connected to a MS Access database (named JSpo2014.accbd ) using the following code :

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("Driver={Microsoft Access Driver (*.mdb, *.accdb)};FIL={MS Access};DSN='';DBQ=C:\\2014\\bd\\JSpo2014.accdb");
db.open();

My Qt application is developed with Qt Creator, using Qt5.3.0 for MinGW x86.

It used to work fine on these configs :

  • WinXP with Office 2010x86 installed
  • Win7x86 with Office 2010x86 installed
  • Win7x86 with Office 2013x86 installed

But it is not working on any of these configs :

  • Win7x64 with Office 2010x86
  • Win7x64 with Office 2013x86
  • Win7x64 with Office 2013x64

I get he following error message :

"[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"

"QODBC3: Unable to connect"

How can I make it work on Win7x64 with Office installed ?

You seem to need a 64 bit driver as you shown everything works on your Windows running in a 32 bit environment, but when you try to run on a 64 bit environment you are unable to connect. Having 32 bit office is not going to solve this problem because windows is still running in a 64 bit environment. You would assume that it should be able to run anything 32 bit inside of a 64 bit environment, however that is not always the case and is never the case trying to run 64 bit inside a 32 bit environment. I would look into trying to get 64 versions if possible. That should negate your problem.

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