Results 1 to 2 of 2

Thread: Please, Urgent help needed: QODBC available but not loaded.

  1. #1
    Join Date
    Mar 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Please, Urgent help needed: QODBC available but not loaded.

    Hi,
    If anyone can help me with this I would be much appreciative.

    So far the output of my app is :

    QSqlDatabase: QODBC driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC

    Which I find incredibly weird.. I compiled the ODBC drivers, and copied them just about everywhere to find where they belong. So now it finds them.
    But when I go to actually use them the lastError() from the connection just gives me "Driver not loaded Driver not loaded"

    Current Code:
    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", con->name().c_str());
    2. if(!QSqlDatabase::isDriverAvailable("QODBC"))
    3. {
    4. cout << "OH HELL NO" << endl;
    5. }
    6. try {
    7. db.setHostName("Adams");
    8. db.setDatabaseName("oms_gdl");
    9. db.setUserName("user");
    10. db.setPassword("fakepasswordhere");
    11. bool ok = db.open();
    12. bool openerror = db.isOpenError();
    13. if (ok && !openerror)
    14. {
    15. }
    16. }catch(...){}
    To copy to clipboard, switch view to plain text mode 

    .pro
    QT += core gui sql xml
    CONFIG += sql
    sql-plugins += odbc

    I have tried 3 or 4 different connection strings, including a terribly attempt at integrated security. :/
    Im terribly new at databases and networking, so any pointers or tutorials would be fantastic.
    So far none of the other forums posts have been of any help past compiling and moving the files into the right directory, one of them seem to have this problem.


    Thanks for any help you can offer.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,579
    Thanks
    13
    Thanked 1,584 Times in 1,513 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Please, Urgent help needed: QODBC available but not loaded.

    Here is how I built and installed the debug plugin using a recent Qt SDK and the bundled MingW tools. The instructions are not far removed from what is in the documentation, total elapsed time 10 minutes.
    Qt Code:
    1. Start Qt command shell
    2. C:\>cd \qtsdk\QtSources\4.7.3\src\plugins\sqldrivers\odbc
    3. C:\QtSDK\QtSources\4.7.3\src\plugins\sqldrivers\odbc> qmake odbc.pro
    4. C:\QtSDK\QtSources\4.7.3\src\plugins\sqldrivers\odbc> mingw32-make
    5. C:\QtSDK\QtSources\4.7.3\src\plugins\sqldrivers\odbc> mingw32-make install
    To copy to clipboard, switch view to plain text mode 
    If you want a release version then the second command becomes:
    Qt Code:
    1. C:\QtSDK\QtSources\4.7.3\src\plugins\sqldrivers\odbc> qmake CONFIG+=release odbc.pro
    To copy to clipboard, switch view to plain text mode 

    So your specific issues:

    Which version of Qt is your app using?
    Which version did you you use to build the ODBC driver?
    Which compiler did you use to build the plugin?
    Where did you place the file?
    Is it a debug or release version?
    Does it match your application?

    What are you passing as the second argument of the addDatabase() call? To be clear, it is not an ODBC connection string.
    What does db.lastError() return after the open() fails?
    What type of ODBC data source are you trying to access?
    Do you have a named ODBC data source called "oms_gdl" in the ODBC adminstrator?
    Have you tested this connection from the administration panel?

    Your PRO file is odd. You only need:
    Qt Code:
    1. QT += sql
    To copy to clipboard, switch view to plain text mode 
    to add SQL support. I have no idea where the other two lines came from. In general a measured approach is better than a scatter gun.
    Last edited by ChrisW67; 14th March 2012 at 08:57.

Similar Threads

  1. QSqlDatabase: QODBC driver not loaded
    By sattu in forum Qt Programming
    Replies: 1
    Last Post: 22nd January 2011, 12:40
  2. QSqlDatabase: QODBC driver not loaded
    By gutiory in forum Qt Programming
    Replies: 1
    Last Post: 14th April 2010, 10:24
  3. QODBC driver not loaded error
    By Askar in forum Qt Programming
    Replies: 0
    Last Post: 23rd October 2009, 11:35
  4. [URGENT] Weird compile error [URGENT]
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2008, 00:54
  5. qodbc driver not loaded error in release mode
    By mandal in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2006, 10:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.