QPlace
3rd November 2008, 19:49
I am using Qt4.5 preview on Windows with VS2008.
I compiled ODBC driver after QT was compiled. Driver was successfully compiled in /plugins/sqldrivers directory of QT tree.
Now, when I am trying to use ODBC driver in my app, I am getting "Driver not loaded" error message. I added "/plugins" subdirectory under my application directory and copied two dlls from Qt45/plugins/sql drivers to <myprojectpath>\plugins. The files that I copied are:
qsqlodbc4.dll
qsqlodbcd4.dll
and also msvcr90.dll, since dependencywalker did find it in these dlls and I did not have it in the PATH.
I have following code:
QApplication::addLibraryPath(QCoreApplication::app licationDirPath() + "/plugins");
QStringList lp = QApplication::libraryPaths();
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
bool isda = QSqlDatabase::isDriverAvailable("QODBC");
db.setDatabaseName("MyApp");
db.setUserName("sa");
db.setPassword("dbpassword");
bool ok = db.open();
I see that variable lp contains directory with odbc plugins, but variable isda is false and of course variable ok is false also.
I will appreciate any tips or hints that can help me to understand what I am doing wrong...
I compiled ODBC driver after QT was compiled. Driver was successfully compiled in /plugins/sqldrivers directory of QT tree.
Now, when I am trying to use ODBC driver in my app, I am getting "Driver not loaded" error message. I added "/plugins" subdirectory under my application directory and copied two dlls from Qt45/plugins/sql drivers to <myprojectpath>\plugins. The files that I copied are:
qsqlodbc4.dll
qsqlodbcd4.dll
and also msvcr90.dll, since dependencywalker did find it in these dlls and I did not have it in the PATH.
I have following code:
QApplication::addLibraryPath(QCoreApplication::app licationDirPath() + "/plugins");
QStringList lp = QApplication::libraryPaths();
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
bool isda = QSqlDatabase::isDriverAvailable("QODBC");
db.setDatabaseName("MyApp");
db.setUserName("sa");
db.setPassword("dbpassword");
bool ok = db.open();
I see that variable lp contains directory with odbc plugins, but variable isda is false and of course variable ok is false also.
I will appreciate any tips or hints that can help me to understand what I am doing wrong...