I am trying to use ODBC driver in one of my Qt5 project.
I compiled QODBC driver and copied the driver dlls to the Qt\Qt5.0.0\5.0.0\msvc2010\plugins\sqldrivers folder.
When I try the following code:
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
I get the following error:
QSqlDatabase: QODBC driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3
Same error is encountered if I tried loading QODBC3.
Even though QODBC and QODBC3 drivers are present, Qt still could not load QODBC driver.
I am running Windows 7 (64 bit) PC.
Has anybody encountered such error? Any clues on what might be wrong ?
I found the issue was caused due to incorrect Visual studio versions used while compiling odbc sql driver.
I had both VS 2008 and VS 2010 in my computer. My Qt5.0 was using VS2010. But when I compiled the odbc sql driver, I had used VS2008. And that caused the problem.
Qt was able to detect the sql odbc driver but could not load it.
I solved this by recompiling the odbc driver using VS2010 and odbc driver works pefectly.
Here are the steps to compile and use sql odbc drivers in Qt 5.0
set vc++ environment variables:
cd into \Qt5.0.0\5.0.0\Src\qtbase\src\plugins\sqldrivers\odbc source folder
qmake odbc.pro
nmake
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With