[Qt-interest] QSqlDatabase with Sqlite question
Dan White
ygor at comcast.net
Thu Nov 19 18:55:03 CET 2009
Just a wild hunch, but try the changes I made in your sample code
“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:
>
> #include <QtCore>
> #include <QtSql>
>
> int main(int argc, char *argv[])
> {
> QCoreApplication a(argc, argv);
>
> // QSqlDatabase connection = QSqlDatabase::addDatabase("QSQLITE"); replace with ---
QSqlDatabase connection = QSqlDatabase::addDatabase("QSQLITE", "mydb");
>
> connection.setDatabaseName("./test.db");
> 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()); replace with ---
QSqlDatabase::removeDatabase( "mydb" );
>
> return a.exec();
> }
>
You call removeDatabase with connection.connectionName() AFTER you closed it. I wonder if that name is usable.
More information about the Qt-interest-old
mailing list