Results 1 to 14 of 14

Thread: "Driver not loaded!"

  1. #1
    Join Date
    Aug 2008
    Posts
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question "Driver not loaded!"

    I am sorry to propose this question again, I tried many ways, still does not solve the problem.
    My platform is VS2008+Qt4.6.0+Win7+Access database, The program (debug version, compiled with /MDd+Use Standard Windows Libraries) runing without problem on my PC, but report "driver not loaded" on another PC which QT is not installed. The program directory inforation is as below.

    E:\TDPDATAPROCESS
    | Microsoft.VC90.CRT.manifest
    | Microsoft.VC90.DebugCRT.manifest
    | msvcm90d.dll
    | msvcp90d.dll
    | msvcr90d.dll
    | QtCored4.dll
    | QtGuid4.dll
    | QtSqld4.dll
    | TDPDataProcess.exe
    | TDPDataProcess.exe.intermediate.manifest
    |
    +---Database
    | DPS_TSDB.mdb
    |
    \---plugins
    \---sqldrivers
    qsqlodbc4.dll
    qsqlodbc4.lib
    qsqlodbcd4.dll
    qsqlodbcd4.lib


    And part of my code is here:
    In main.cpp, set the lib path.
    Qt Code:
    1. QStringList pathList=QApplication::libraryPaths();
    2. pathList.append(QDir::current().absolutePath()+"/plugins");
    3. pathList.append(QApplication::applicationDirPath()+"/plugins");
    4. QApplication::setLibraryPaths(pathList);
    To copy to clipboard, switch view to plain text mode 

    connect to database
    Qt Code:
    1. bool TDPDataProcess::connectToDatabase(QString& szAccessFile)
    2. {
    3. QSqlDatabase connection = QSqlDatabase::addDatabase("QODBC");
    4.  
    5. "DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=%1").arg(szAccessFile);
    6.  
    7. connection.setDatabaseName(dsn);
    8. if (!connection.open())
    9. {
    10. QMessageBox::warning(NULL,tr("Failed to connect database"),connection.lastError().text());
    11. return false;
    12. }
    13.  
    14. return true;
    15. }
    To copy to clipboard, switch view to plain text mode 

    Does anybody has some idea to solve this problem? Any help is appreciated
    Last edited by bangqianchen; 12th July 2010 at 08:26.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: "Driver not loaded!"

    Does the first snippet run before QApplication constructor or after it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: "Driver not loaded!"

    Is the directory sqldrivers inside plugins? And you also can try to use qt.conf inside the root directory.

  4. #4
    Join Date
    Aug 2008
    Posts
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: "Driver not loaded!"

    1. The program is OK on my computer, and the program is started on the other PC, but reporting error when connect to the database.

    2. sqldrivers inside plugins directory. BWT, what's this mean? "try to use qt.conf inside the root directory", I am on the window platform.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: "Driver not loaded!"

    Please answer my question.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: "Driver not loaded!"

    Quote Originally Posted by bangqianchen View Post
    BWT, what's this mean? "try to use qt.conf inside the root directory", I am on the window platform.
    See http://doc.trolltech.com/4.6/qt-conf.html

    What I did is, make a sample application (or alter your existing) and print QCoreApplication::libraryPaths() to a file/message popup/... and see where Qt looks for the plugins.

    EDIT: again 2nd.

  7. #7
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: "Driver not loaded!"

    You don't need to add additional library path, just move your sqldrivers directory to your application directory.

  8. #8
    Join Date
    Aug 2008
    Posts
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: "Driver not loaded!"

    I am sorry, my english is poor and misunderstand "Does the first snippet run before QApplication constructor or after it? "
    the code is after QApplication constructor, the following is the code.

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "TDPDataProcess.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7.  
    8. QStringList pathList=QApplication::libraryPaths();
    9. pathList.append(QDir::current().absolutePath()+"/plugins");
    10. pathList.append(QApplication::applicationDirPath()+"/plugins");
    11. QApplication::setLibraryPaths(pathList);
    12.  
    13. QTextCodec* codec = QTextCodec::codecForLocale();
    14. QTextCodec::setCodecForLocale(codec);
    15. QTextCodec::setCodecForCStrings(codec);
    16. QTextCodec::setCodecForTr(codec);
    17.  
    18. TDPDataProcess w;
    19. w.show();
    20. return a.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    Aug 2008
    Posts
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: "Driver not loaded!"

    Quote Originally Posted by saa7_go View Post
    You don't need to add additional library path, just move your sqldrivers directory to your application directory.
    I had try, It's does not work! and I added some test code to show the library path

    Qt Code:
    1. QStringList pathList=QApplication::libraryPaths();
    2. pathList.append(QDir::current().absolutePath()+"/plugins");
    3. pathList.append(QApplication::applicationDirPath()+"/plugins");
    4. QApplication::setLibraryPaths(pathList);
    5.  
    6. QString szt;
    7. for(int idx=0; idx<pathList.count(); idx++)
    8. szt += pathList.at(idx) + QObject::tr("\n");
    9. QMessageBox::warning(NULL,QObject::tr("Library path"),szt);
    To copy to clipboard, switch view to plain text mode 

    When exec this program on other PC, the dialog shown that the "xxx/plugins" had successfully added as library path.

  10. #10
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: "Driver not loaded!"

    Quote Originally Posted by bangqianchen View Post
    I had try, It's does not work! and I added some test code to show the library path
    What do you mean it's does not work? The driver is not loaded?

    When you move your sqldrivers directory to your application directory, does your files and direcotory structures look like this:

    E:\TDPDATAPROCESS
    | Microsoft.VC90.CRT.manifest
    | Microsoft.VC90.DebugCRT.manifest
    | msvcm90d.dll
    | msvcp90d.dll
    | msvcr90d.dll
    | QtCored4.dll
    | QtGuid4.dll
    | QtSqld4.dll
    | TDPDataProcess.exe
    | TDPDataProcess.exe.intermediate.manifest
    |
    +---Database
    | DPS_TSDB.mdb
    |
    +---sqldrivers
    | qsqlodbcd4.dll

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: "Driver not loaded!"

    You need to set library paths for QApplication before creating the application object. The methods you need to call are static so they can be called without an object. If you use them after the application object is already created, plugins will not be loaded as they are loaded in the constructor of the application object.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Aug 2008
    Posts
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: "Driver not loaded!"

    Quote Originally Posted by wysota View Post
    You need to set library paths for QApplication before creating the application object. The methods you need to call are static so they can be called without an object. If you use them after the application object is already created, plugins will not be loaded as they are loaded in the constructor of the application object.
    Thanks for replying, however, it sames not the case, I had try as you suggested.

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QStringList pathList=QApplication::libraryPaths();
    4. pathList.append(QDir::current().absolutePath()+"/plugins");
    5. pathList.append(QApplication::applicationDirPath()+"/plugins");
    6. QApplication::setLibraryPaths(pathList);
    7.  
    8. /*QString szt;
    9. for(int idx=0; idx<pathList.count(); idx++)
    10. szt += pathList.at(idx) + QObject::tr("\n");
    11. QMessageBox::warning(NULL,QObject::tr("Library path"),szt);*/
    12.  
    13. QApplication a(argc, argv);
    14.  
    15. QTextCodec* codec = QTextCodec::codecForLocale();
    16. QTextCodec::setCodecForLocale(codec);
    17. QTextCodec::setCodecForCStrings(codec);
    18. QTextCodec::setCodecForTr(codec);
    19.  
    20. TDPDataProcess w;
    21. w.show();
    22. return a.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 

  13. #13
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: "Driver not loaded!"

    Btw, you can try to link qsqlodbc plugin staticaly. So you don't need to worry about library path.

  14. #14
    Join Date
    Nov 2007
    Posts
    6
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: "Driver not loaded!"

    I had the same problem with Qt4.6 on WinXP.

    I tried addLibraryPath() and setLibraryPaths(). Also tried qt.conf file. Nothing seemingly worked. It will always fallback to %QT_DIR%/plugins directory.

    Last resort, I added QT_PLUGIN_PATH in the system environment variable, copied sqldrivers/ into the root directory of the EXE file, it works!

    I added QT_PLUGIN_PATH with the value . (a dot) to signify look at the current directory.

Similar Threads

  1. Replies: 1
    Last Post: 24th April 2010, 03:43
  2. Replies: 4
    Last Post: 10th November 2009, 19:48
  3. The strange problem:"QSqlDatabase: QMYSQL driver not loaded"
    By osmanthus in forum Installation and Deployment
    Replies: 2
    Last Post: 22nd January 2009, 15:12
  4. The PostgreSQL plugin is not loaded in "SQL Browser" example
    By Scratch in forum Installation and Deployment
    Replies: 1
    Last Post: 18th November 2008, 01:30
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.