[Qt-interest] QSqlDatabase with Sqlite question

Dan White ygor at comcast.net
Thu Nov 19 21:09:30 CET 2009


I still suspect connection.connectionName()
Would you be willing to add a few qDebug statements to print out its value at several points in the program ?

“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)

----- KC Jones <kc at asperasoft.com> wrote:
> 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();
> }
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest





More information about the Qt-interest-old mailing list