[Qt-interest] QSqlDatabase with Sqlite question

KC Jones kc at asperasoft.com
Thu Nov 19 20:43:17 CET 2009


Thanks for all the advice.  Somehow, I'm still not arriving at a
solution.  (BTW: Providing an explicit name for the connection only
seemed to make matters worse.)  But following Jason's advice as I
understood it, I now have this code, still plagued by the same warning
message:

#include <QtCore>
#include <QtSql>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QFile::remove("./test.db");
    QSqlDatabase connection = QSqlDatabase::addDatabase("QSQLITE");

    connection.setDatabaseName("./test.db");
    if (connection.open())
    {
        QSqlQuery* q = new QSqlQuery();
        q->exec("CREATE TABLE foo2 ( id integer PRIMARY KEY, bar integer );");
        delete q;
        connection.close();
    }

    QSqlDatabase::removeDatabase(connection.connectionName());

    return a.exec();
}



More information about the Qt-interest-old mailing list