Results 1 to 5 of 5

Thread: QSqlDatabase::open() fails with QODBC

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Location
    ŁÃ³dź, Poland
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QSqlDatabase::open() fails with QODBC

    [solved]

    Hi everyone,

    I've searched the forum, but none of the previous odbc-related threads has answered my question... I can't open an ODBC data source, my program (sample source below) fails with an obscure error message which reads:

    "Driver not loaded Driver not loaded"

    Yes, it's repeated twice. I try to connect to a database (either MySQL or PostgreSQL) through unix odbc. I have the drivers installed and configured, as well as samle DSNs, and I can browse throug them with DataManager - everything works fine. I've compiled the QSqlODBC plugin from sources (the same version as the library I have installed from Debian's packages) and put it in /usr/lib/qt4/pluings/sqldrivers. The QSqlDatabase::drivers() returns:

    ("QPSQL7", "QPSQL", "QMYSQL3", "QMYSQL", "QSQLITE", "QSQLITE2", "QODBC3", "QODBC")

    Therefore I belive that the plugin is ok. Just to make sure, I've tried to compile it with ODBC_CHECK_DRIVER undefined, as suggested in the documentation - no luck.

    My code looks like:

    Qt Code:
    1. db.addDatabase("QODBC");
    2. db.setDatabaseName("Driver={MySQL};Server=localhost;Database=test;Uid=test;Pwd=test;");
    3. if(!db.open()) {
    4. qDebug() << db.lastError().text();
    5. exit(1);
    6. }
    To copy to clipboard, switch view to plain text mode 

    Any clues?
    Last edited by grzywacz; 22nd August 2006 at 17:51.
    Kind regards,
    Karol "grzywacz" Nowak

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
  •  
Qt is a trademark of The Qt Company.