PDA

View Full Version : [QT4.1] QSqlDatabase duplicate connection error.



freak
21st June 2006, 20:51
I have different areas on my sources where I declare a database object with addDatabase. When I run my code I get the following error.



QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.


What is the best way of fixing this problem?

Thanks in advanced.

jacek
21st June 2006, 20:57
You can only have one default connection opened --- either reuse it or create connections with different names.

ball
22nd June 2006, 06:45
QSqlDatabase::addDatabase("QOCI","db1");
QSqlDatabase::addDatabase("QMYSQL","db2");

never use like this:
QSqlDatabase::addDatabase();

becoz that will use the default connection which can only be used once

jacek
22nd June 2006, 16:27
never use like this:
QSqlDatabase::addDatabase();
Not never --- just at most once. ;)