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. Error message (ODBC) "Driver not loaded" after upgrade from Qt 4.6.1 to 4.7.3
Forum Updated to NodeBB v4.3 + New Features

Error message (ODBC) "Driver not loaded" after upgrade from Qt 4.6.1 to 4.7.3

Scheduled Pinned Locked Moved General and Desktop
15 Posts 5 Posters 13.3k Views 1 Watching
  • 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.
  • O Offline
    O Offline
    o2t2
    wrote on last edited by
    #1

    Hi,

    I'm using a simple WinXp 32-bit machine with MS VC Express for developing with Qt.
    After upgrading from Qt 4.6.1 to Qt 4.7.3 and recompiling my source code the QSqlDatabase::open() function fails with error message "Driver not loaded". My code for this kept unchanged and nothing else in the environment has been changed except the environment variable "QTDIR". It is now pointing to the QT 4.7.3 "home directory" instead to QT 4.6.1 "home directory".

    @
    QSqlDatabase m_db;
    m_db = QSqlDatabase::addDatabase("QODBC");
    m_db.setDatabaseName(databaseName);
    m_db.setUserName(userName);
    m_db.setPassword(password);

    QSqlError m_lastError;
    bool ok = m_db.open();
    if (!ok)
    {
    m_lastError = m_db.lastError(); // returns "Driver not loaded"
    }
    @

    The drivers check with debug instruction
    @
    QString s( QSqlDatabase::drivers().join( "." )) ;
    @
    shows in Qt 4.6.1 "QSQLITE.QODBC3.QODBC", but in Qt 4.7.3 only "QSQLITE".
    I have no idea why Qt 4.7.3 does not load the ODBC drivers.

    Any help is very welcome.

    Regards
    o2t2

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Do you have the other drivers available in your new Qt version?

      1 Reply Last reply
      0
      • O Offline
        O Offline
        o2t2
        wrote on last edited by
        #3

        How to check it ?
        I thought I did it with the
        @
        QString s( QSqlDatabase::drivers().join( "." )) ;
        @

        line...

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Well, you could just look at what drivers you have.
          They should be in your Qt "root" under plugins/sqldrivers.

          1 Reply Last reply
          1
          • O Offline
            O Offline
            o2t2
            wrote on last edited by
            #5

            Thanks. There are only qsqllite* files. What a pitty :)

            Sorry for the simple questions, but: Where are the others? How to build or install them?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              Check the "documentation":http://developer.qt.nokia.com/doc/qt-4.7/sql-driver.html#id-9b35bbe5-e3f8-4d40-b01a-08db65bd5f40 here.

              1 Reply Last reply
              0
              • O Offline
                O Offline
                o2t2
                wrote on last edited by
                #7

                Googeled a little bit and found this

                http://doc.qt.nokia.com/latest/sql-driver.html

                section "QODBC for Open Database Connectivity (ODBC)"

                After the qmake command all works fine.

                Thanks for help, Andre.

                Regards

                o2t2

                1 Reply Last reply
                0
                • O Offline
                  O Offline
                  o2t2
                  wrote on last edited by
                  #8

                  Oh, one's more, Andre:

                  Neither in the %QTDIR%\plugins\sqldrivers directory nor in the src\plugins\sqldrivers\odbc directory there are no odbc driver dlls or libs.
                  Where they are ? (Searching in windows explorer does not bring a result...)
                  Why does it work now ?

                  Background: The drivers have also to be installed at customer site...

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #9

                    They should appear in QTDIR\plugins\sqldrivers. If they do not, then something wend wrong with building them, I think.

                    If you install them at your customers site, I would recommend you do not install Qt as a shared library, at least not if Windows is your target platform (most likely when using ODBC). Instead, put Qt libs in the same directory as the executable, and the plugins you need in folders with the names corresponding to what you find inside QTDIR\plugins (that is: ommit the plugins\ directory level itself). That way, your app will find the right Qt libraries, and Qt will find its plugins without you having to do anything else.

                    1 Reply Last reply
                    0
                    • O Offline
                      O Offline
                      o2t2
                      wrote on last edited by
                      #10

                      Andre,

                      the "plugins\sqldrivers" directory do not have any odbc files. Crazy.
                      But i looked once more into the command window where I called qmake and nmake and I see, that nmake failed because the nmake command was not found on the system. May this be the cause for missing odbc dll in "plugins\sqldrivers" ?
                      If yes: Where resides the nmake? Again: Searching in windows explorer does not bring a result…

                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        loladiro
                        wrote on last edited by
                        #11

                        Are you using MSVC or MinGW? If you are using the latter you have to use mingw32-make instead of nmake. If you are using the former, please use the MSVC Command Prompt, that automatically configures the paths to all the necessary tools.

                        1 Reply Last reply
                        0
                        • O Offline
                          O Offline
                          o2t2
                          wrote on last edited by
                          #12

                          I'm using MSVC. Your tip with the MSVC Command Prompt was the key to success.

                          Now I have the drivers in the plugins/sqldrivers directory.

                          Thanks once more, Andre.

                          Regards

                          o2t2

                          1 Reply Last reply
                          0
                          • O Offline
                            O Offline
                            o2t2
                            wrote on last edited by
                            #13

                            Next question related to this thread: The genration of the driver succeeded and they work fine inside the development environment (Win XP, MSVC2008).
                            Copied the generated exe and dlls to the runtime environment (MS 2008 Server R2), installed the data source (ODBC) as well as in the development environment.

                            The same error message “Driver not loaded" occurs. So I copied the qsqlodbc.dll too. Same error message. What's wrong ?

                            Regards

                            o2t2

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              chandan
                              wrote on last edited by
                              #14

                              I am not able to connect any database successfully.Why this kind of problem generally occurs for a standardize software like QT.

                              1 Reply Last reply
                              0
                              • F Offline
                                F Offline
                                francomartins
                                wrote on last edited by
                                #15

                                @
                                QString ipserver,LoginName,database,Pass;
                                QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "MyDatabase");

                                db.setDatabaseName("DRIVER={SQL Server};Server="+ipserver+";Database="+database+";Uid="+LoginName+";Port=1433;Pwd="+Pass+";WSID=");

                                if(db.open())
                                {
                                qDebug() << "Opened";
                                db.close();
                                }
                                else
                                qDebug() << "Error" << db.lastError().text();
                                @
                                the WSID =. “is used to hide the client machine to the database server log ,is optional .

                                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