Tiansen
8th June 2022, 20:08
I want to use two separate databases over ODBC in my application.
If I do something like this:
db_serno=QSqlDatabase::addDatabase("QODBC");
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?
If I do something like this:
db_serno=QSqlDatabase::addDatabase("QODBC");
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?