PDA

View Full Version : QODBC Driver not loaded after successfull connection and query



axed
13th October 2014, 14:21
Hello everbody,

i have a strange situation/behaviour with the QODBC driver.

I've deployed the application with all the release-libraries (Windows 7 x32).
When i do a simple QSqlDatabase connect with the QODBC driver, everything works well, including a QSqlQuery task.



QSqlDatabase myDb = QSqlDatabase::addDatabase("QODBC", "myDb123");
myDb.setDatabaseName("my odbc connection string");
if (!myDb.open()) {
qDebug() << myDb.lastError().text();
}
// do query and other funny things like int omg = 12/0;


But .. when i do the exact same thing a second time at runtime, i get a "DRIVER NOT LOADED. DRIVER NOT LOADED." error.

When i restart the application i get the excat behaviour again: SUCCESS; then FAIL; FAIL; FAIL...

To be honest i dont really know how to isolate the problem.
Anyone has an idea why this might occur?

west
13th October 2014, 19:16
Try this:


if ( ! db.isOpen() )
{
if ( ! db.open() )
{
qWarning();
}
}

axed
13th October 2014, 19:35
Thank you for your answer,
but nevermind... i found the problem.
The second QSqlDatabase instance was created with the same **:mad:** connectionName.
I have no idea how this could result in an error like "Driver not loaded" but hey it's working now.'
yay!