Hi
I am struggling to release a database file I use with QSqlDatabase. I need the ability to close the connection and then delete the database file before replacing it with a new database. I can't delete it because the my program is holding onto it. I create my connection using the code below and dbProject is define globally for now.
bool createDBConnection() {
}
dbProject.setDatabaseName(active_db_file);
if (!dbProject.open()) {
// Error messages
}
return dbProject.isValid();
}
bool createDBConnection() {
if (QSqlDatabase::connectionNames().isEmpty()) {
dbProject = QSqlDatabase::addDatabase("QSQLITE");
}
dbProject.setDatabaseName(active_db_file);
if (!dbProject.open()) {
// Error messages
}
return dbProject.isValid();
}
To copy to clipboard, switch view to plain text mode
To release the file I am trying:
dbProject.close();
dbProject.close();
To copy to clipboard, switch view to plain text mode
According to the QT docs it seems like this should be good enough. Does anybody know why it does not work?
Thanks
Jaco
Bookmarks