Error in loading SQLITE driver in MeeGo App



  • Hi,

    I've run into a weird error while working with databases using QtSql. I created a database using the QSQLITE driver and the default connection name and am able to access it properly. However in my application, I am also using the QMessageService class and according to the logs, it also uses the default connection name and removes the connection I am currently using. After I'm done with the QMessageService class, all my calls to the database are no longer valid since my connection was removed.

    To address this, I tried to define a connection name when I call QSqlDatabase::addDatabase(). The logs report that the database is successfully opened, however, when I try to perform any queries it says that the database driver is not loaded.

    @
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "myConn");
    db.setDatabaseName("myDbName");
    if(db.open()) qDebug() << "Successfully opened database";
    @

    Then any query I perform, the error logs : QSqlError(-1, "Driver not loaded", "Driver not loaded").

    The code was working perfectly without setting the connection name. But the issue with that is that the QMessageService class removes the default connection.

    Why is this so? How can I ensure that my database connection isn't removed by any other process in the system?

    Cef


Log in to reply
 

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