Using two separate databases over ODBC inside a class fails
I want to use two separate databases over ODBC in my application.
If I do something like this:
Code:
db_serno.setDatabaseName("AccDB");
db_serno.open();
db_serno.exec(<SQL_QUERY>); <-- query performs successfully
db
=QSqlDatabase::addDatabase("QODBC");
// trying to add another ODBC connection to another DB
db_serno.exec(<SQL_QUERY>); <-- query fails (last error is: Driver not loaded)
It seems that second addDatabase() somehow corrupts also the first odbc object. Obviously I am doing something wrong, how can I fix it?
Re: Using two separate databases over ODBC inside a class fails
Hi, the docs for QSqlDatabase::addDatabase() say:
Quote:
Warning: If you add a connection with the same name as an existing connection, the new connection replaces the old one. If you call this function more than once without specifying connectionName, the default connection will be the one replaced.
So try passing a connection name as second parameter to QSqlDatabase::addDatabase().
Ginsengelf
Re: Using two separate databases over ODBC inside a class fails
Quote:
Originally Posted by
Ginsengelf
Hi, the docs for QSqlDatabase::addDatabase() say:
So try passing a connection name as second parameter to QSqlDatabase::addDatabase().
Ginsengelf
Thank you, that is working!!