Mam program, w ktorym musze uzyc 2 roznych baz danych. Tworze je w ten sposob:
QSqlDatabase db1;
//tworzenie bazy i otwieranie bazy
db1 = QSqlDatabase::addDatabase("QSQLITE");
db1.setHostName("localhost");
db1.setDatabaseName("./users.gdb");
db1.setUserName("users");
db1.setPassword("users");
if (!db1.open()) {
QMessageBox::critical(0, "Error","Error during opening the database");
exit(1);
}
QSqlDatabase db1;
//tworzenie bazy i otwieranie bazy
db2 = QSqlDatabase::addDatabase("QSQLITE");
db2.setHostName("localhost");
db2.setDatabaseName("./admin.gdb");
db2.setUserName("admin");
db2.setPassword("admin");
if (!db2.open()) {
QMessageBox::critical(0, "Error","Error during opening the database");
exit(1);
}
I doastaje taki komunikat:
QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
Czytalem to: http://www.qtcentre.org/threads/12759-Multiple-database-connections i mniej wiecej juz wiem, skad ten blad sie bierze - pytanie tylko - jak sie go pozbyc? Jak uzywac 2 baz danych w tym samym czasie w Qt?