Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlDatabase: QODBC driver not loaded - problem
QtWS25 Last Chance

QSqlDatabase: QODBC driver not loaded - problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 4 Posters 9.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ArtursA Offline
    ArtursA Offline
    Arturs
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

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

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • ArtursA Offline
        ArtursA Offline
        Arturs
        wrote on last edited by Arturs
        #3

        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-install

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

        beeckscheB 1 Reply Last reply
        0
        • ArtursA Arturs

          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-install

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

          beeckscheB Offline
          beeckscheB Offline
          beecksche
          wrote on last edited by beecksche
          #4

          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
          nmake
          

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

          Hope this helps

          1 Reply Last reply
          2
          • ArtursA Offline
            ArtursA Offline
            Arturs
            wrote on last edited by
            #5

            you helps a lot.

            I did everything as described above.

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

            beeckscheB 1 Reply Last reply
            0
            • ArtursA Arturs

              you helps a lot.

              I did everything as described above.

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

              beeckscheB Offline
              beeckscheB Offline
              beecksche
              wrote on last edited by beecksche
              #6

              @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
              
              beeckscheB 1 Reply Last reply
              0
              • ArtursA Offline
                ArtursA Offline
                Arturs
                wrote on last edited by Arturs
                #7

                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.pro

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

                1 Reply Last reply
                0
                • beeckscheB beecksche

                  @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
                  
                  beeckscheB Offline
                  beeckscheB Offline
                  beecksche
                  wrote on last edited by
                  #8

                  I have updated my post:

                  @beecksche said:

                  @Arturs
                  ...
                  Update:
                  I am not quite sure but take a look at this directory:

                  %QTDIR%\qtbase\plugins\sqldrivers
                  
                  1 Reply Last reply
                  0
                  • ArtursA Offline
                    ArtursA Offline
                    Arturs
                    wrote on last edited by Arturs
                    #9

                    screen of catalogue D:\qt-everywhere-opensource-src-5.6.0\qt-everywhere-opensource-src-5.6.0\qtbase\src\plugins\sqldrivers after compilation

                    .moc
                    .obj
                    .pch

                    are empty.

                    beeckscheB 1 Reply Last reply
                    0
                    • hskoglundH Offline
                      hskoglundH Offline
                      hskoglund
                      wrote on last edited by
                      #10

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

                      1 Reply Last reply
                      0
                      • ArtursA Arturs

                        screen of catalogue D:\qt-everywhere-opensource-src-5.6.0\qt-everywhere-opensource-src-5.6.0\qtbase\src\plugins\sqldrivers after compilation

                        .moc
                        .obj
                        .pch

                        are empty.

                        beeckscheB Offline
                        beeckscheB Offline
                        beecksche
                        wrote on last edited by beecksche
                        #11

                        @Arturs

                        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.

                        1 Reply Last reply
                        0
                        • ArtursA Offline
                          ArtursA Offline
                          Arturs
                          wrote on last edited by Arturs
                          #12

                          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"

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved