QSqlDatabase: QODBC driver not loaded - problem

  • Hi

    I have the following code :

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QDebug>
    #include <QSqlDatabase>
    #include <QSqlQuery>
    MainWindow::MainWindow(QWidget *parent) :
        ui(new Ui::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");

    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.


  • It's a "feature" of Qt 5.6, see https://bugreports.qt.io/browse/QTBUG-49420 for report and solution

  • 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 release
    nmake install
    nmake release-install

    I am quite new in QT so I do not know how to do above procedure. Where can I download odbc.pro ?

  • Hi @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

    If you are not using a Microsoft compiler, replace nmake with make in the line above.

    Hope this helps

  • you helps a lot.

    I did everything as described above.

    What files should be result of ? What to do next ?

  • @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.

    I am not quite sure but take a look at this directory:


  • 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:


    after compiling are more files but there are not any dll files

  • I have updated my post:

    @beecksche said:

    I am not quite sure but take a look at this directory:


  • 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).

  • @Arturs

    You are in the wrong directory. I think in your case it should be:


    or download the new Qt 5.6.1 (released on 8th of June 2016), like @hskoglund said.

  • 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"

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.