QSqlDatabase: QODBC driver not loaded - problem
-
wrote on 6 Jun 2016, 10:02 last edited by
Hi
I have the following code :
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QDebug> #include <QSqlDatabase> #include <QSqlQuery> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { QSqlDatabase db = QSqlDatabase::addDatabase("QODBC"); db.setDatabaseName("Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=d:/TEST"); db.open(); }
after pressing button I see the messages "
QSqlDatabase: QODBC driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7"How to solve the problem ?
How to load the driver.I use Windows 7 64bit.
Regards
Artur -
wrote on 6 Jun 2016, 10:46 last edited by VRonin 6 Jun 2016, 10:47
It's a "feature" of Qt 5.6, see https://bugreports.qt.io/browse/QTBUG-49420 for report and solution
-
wrote on 6 Jun 2016, 17:09 last edited by Arturs 6 Jun 2016, 17:26
Thank you for information. Now Everything is clear and know why I spent so many hours and still problem with ODBC.
ODBC Build Steps
cd c:/Qt/Qt5.6.0/5.6/Src/qtbase/src/plugins/sqldrivers/odbc
qmake odbc.pro
nmake
nmake release
nmake install
nmake release-installI am quite new in QT so I do not know how to do above procedure. Where can I download odbc.pro ?
-
Thank you for information. Now Everything is clear and know why I spent so many hours and still problem with ODBC.
ODBC Build Steps
cd c:/Qt/Qt5.6.0/5.6/Src/qtbase/src/plugins/sqldrivers/odbc
qmake odbc.pro
nmake
nmake release
nmake install
nmake release-installI am quite new in QT so I do not know how to do above procedure. Where can I download odbc.pro ?
wrote on 6 Jun 2016, 17:37 last edited by beecksche 6 Jul 2016, 12:13Hi @Arturs,
you need to download the source files of Qt 5.6 and then take a look here http://doc.qt.io/qt-5.6/sql-driver.html#qodbc-for-open-database-connectivity-odbc, section How to Build the ODBC Plugin on Windows. It says:The ODBC header and include files should already be installed in the right directories. You just have to build the plugin as follows:
cd %QTDIR%\qtbase\src\plugins\sqldrivers\odbc qmake odbc.pro nmake
If you are not using a Microsoft compiler, replace nmake with make in the line above.
Hope this helps
-
wrote on 7 Jun 2016, 05:01 last edited by
you helps a lot.
I did everything as described above.
What files should be result of ? What to do next ?
-
you helps a lot.
I did everything as described above.
What files should be result of ? What to do next ?
wrote on 7 Jun 2016, 06:39 last edited by beecksche 6 Jul 2016, 07:10@Arturs
The lines above should create your necessary libraries (dlls / libs).
I have done this a long time ago, so i do not remeber where the files are created, sorry for that.Update:
I am not quite sure but take a look at this directory:%QTDIR%\qtbase\plugins\sqldrivers
-
wrote on 7 Jun 2016, 18:36 last edited by Arturs 6 Jul 2016, 18:37
I am not sure that I install plugin in proper way.
In readme file is the following information:
"You will need ODBC development headers and libraries installed before
compiling this plugin."Where to find headers and libriaries ?
What I did:
- downloaded qt sources
- open odbc catalogue - cd %QTDIR%\qtbase\src\plugins\sqldrivers\odbc in command prompt
- used the command - qmake odbc.pro
before using the command in the catalogue were only the files:
main.cpp
odbc.json
odbc.proafter compiling are more files but there are not any dll files
-
@Arturs
The lines above should create your necessary libraries (dlls / libs).
I have done this a long time ago, so i do not remeber where the files are created, sorry for that.Update:
I am not quite sure but take a look at this directory:%QTDIR%\qtbase\plugins\sqldrivers
wrote on 8 Jun 2016, 18:59 last edited byI have updated my post:
@beecksche said:
@Arturs
...
Update:
I am not quite sure but take a look at this directory:%QTDIR%\qtbase\plugins\sqldrivers
-
wrote on 9 Jun 2016, 04:14 last edited by Arturs 6 Sept 2016, 04:14
-
wrote on 9 Jun 2016, 04:35 last edited by
Hi, there's an alternative solution: if you update to Qt 5.6.1 the QODBC driver plugin is included again (just like it was before Qt 5.6).
-
wrote on 9 Jun 2016, 06:20 last edited by beecksche 6 Sept 2016, 06:22
You are in the wrong directory. I think in your case it should be:
D:\qt-everywhere-opensource-src-5.6.0\qt-everywhere-opensource-src-5.6.0\qtbase\plugins\sqldrivers
or download the new Qt 5.6.1 (released on 8th of June 2016), like @hskoglund said.
-
wrote on 9 Jun 2016, 07:09 last edited by Arturs 6 Sept 2016, 08:35
I installed new version of Qt 5.6.1 for Windows 64-bit (VS 2015, 836 MB) (info) but now during compilation I have the following error:
"Error while building/deploying project Gunsbase (kit: Desktop Qt 5.6.1 MSVC2015 64bit) When executing step "Make"
4/12