QSqlDatabase common problem
-
why do i get this error : QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
i already follow what's in the docs...
@
window::window()
{
{
db = QSqlDatabase::addDatabase("QMYSQL");
// query here
query.clear();
db.close();
}
QSqlDatabase.removeDatabase("QMYSQL");
}
@ -
http://doc.trolltech.com/4.2/qsqldatabase.html#addDatabase
can you check with this if DB is still open?
bool db.isOpen()
QDatabase::removeDatabase("databaseName"); -
i just found this "thread":http://developer.qt.nokia.com/forums/viewthread/328/
-
i limit the error by doing something like this
@
window::window() {
QString conn = db.connectionName();
if (conn.isEmpty()) {
db = QSqlDatabase::addDatabase("QMYSQL");
}
}
window::close() {
QSqlDatabase::removeDatabase("QMYSQL");
}
@but this is not enough coz tha last query still displays the error coz the dbase is not remove...
-
[quote author="xeroblast" date="1293007954"]but this is not enough coz tha last query still displays the error coz the dbase is not remove...[/quote]
Off topic: could you try to write normal English please? "coz" "tha" etc. do not qualify. That would make your comments much easier to read. Thank you.