PDA

View Full Version : Please, Urgent help needed: QODBC available but not loaded.



Mythical_Man
14th March 2012, 05:41
Hi,
If anyone can help me with this I would be much appreciative.

So far the output of my app is :

QSqlDatabase: QODBC driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC

Which I find incredibly weird.. I compiled the ODBC drivers, and copied them just about everywhere to find where they belong. So now it finds them.
But when I go to actually use them the lastError() from the connection just gives me "Driver not loaded Driver not loaded"

Current Code:



QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", con->name().c_str());
if(!QSqlDatabase::isDriverAvailable("QODBC"))
{
cout << "OH HELL NO" << endl;
}
try {
db.setHostName("Adams");
db.setDatabaseName("oms_gdl");
db.setUserName("user");
db.setPassword("fakepasswordhere");
bool ok = db.open();
bool openerror = db.isOpenError();
if (ok && !openerror)
{
}
}catch(...){}


.pro
QT += core gui sql xml
CONFIG += sql
sql-plugins += odbc

I have tried 3 or 4 different connection strings, including a terribly attempt at integrated security. :/
Im terribly new at databases and networking, so any pointers or tutorials would be fantastic.
So far none of the other forums posts have been of any help past compiling and moving the files into the right directory, one of them seem to have this problem.


Thanks for any help you can offer.

ChrisW67
14th March 2012, 07:50
Here is how I built and installed the debug plugin using a recent Qt SDK and the bundled MingW tools. The instructions are not far removed from what is in the documentation, total elapsed time 10 minutes.


Start Qt command shell
C:\>cd \qtsdk\QtSources\4.7.3\src\plugins\sqldrivers\odbc
C:\QtSDK\QtSources\4.7.3\src\plugins\sqldrivers\od bc> qmake odbc.pro
C:\QtSDK\QtSources\4.7.3\src\plugins\sqldrivers\od bc> mingw32-make
C:\QtSDK\QtSources\4.7.3\src\plugins\sqldrivers\od bc> mingw32-make install

If you want a release version then the second command becomes:


C:\QtSDK\QtSources\4.7.3\src\plugins\sqldrivers\od bc> qmake CONFIG+=release odbc.pro


So your specific issues:

Which version of Qt is your app using?
Which version did you you use to build the ODBC driver?
Which compiler did you use to build the plugin?
Where did you place the file?
Is it a debug or release version?
Does it match your application?

What are you passing as the second argument of the addDatabase() call? To be clear, it is not an ODBC connection string.
What does db.lastError() return after the open() fails?
What type of ODBC data source are you trying to access?
Do you have a named ODBC data source called "oms_gdl" in the ODBC adminstrator?
Have you tested this connection from the administration panel?

Your PRO file is odd. You only need:


QT += sql

to add SQL support. I have no idea where the other two lines came from. In general a measured approach is better than a scatter gun.