Results 1 to 12 of 12

Thread: ODBC Database plugin is not loading

  1. #1
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default ODBC Database plugin is not loading

    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...

  2. #2
    Join Date
    May 2006
    Location
    Germany
    Posts
    108
    Thanks
    2
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ODBC Database plugin is not loading

    Try putting it into plugins\sqldrivers.

    If that does not help then check with LDD / DepedencyWalker if you are missing any further libraries.
    "If you lie to the compiler, it will get its revenge." - Henry Spencer

  3. #3
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ODBC Database plugin is not loading

    Did not help. Dependency walker does not show any gross violations. The most important were msvcr90.dll and msvcr90d.dll that I put straight in the plugins\sqldrivers

    How can I debug this thing or figure out the reason for this cryptic "Driver not loaded" message? May be I have to call addLibraryPath in some other place? I am at lost

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ODBC Database plugin is not loading

    Do you create QCoreApplication or QApplication instance?

  5. #5
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ODBC Database plugin is not loading

    I created QApplication, not QCoreApplication.

  6. #6
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ODBC Database plugin is not loading

    Here is what I found (and I don't know how to explain the results):

    I added directory where I want to load database plugins to with the call to
    QApplication::addLibraryPath("mypath");

    Then I call QApplication::libraryPaths(). It returns three paths in that order:

    <mypath>
    <qtpath\plugins>, where qtpath is a path to the root of QT tree
    <application path>

    I had ODBC drivers qsqlodbc4.dll in <mypath> directory. Under <qtpath\plugins there is sqlplugins directory which I intentionally left empty. My reasoning was that if I put database drivers into <mypath> directory QT should find them because of addLibraryPath call. That assumption was incorrect; ODBC driver failed to load. Only when I copied ODBC driver back to qtpath\plugins\sqldrivers directory they loaded OK.

    Now the question is: Why that is happening?

  7. #7
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: ODBC Database plugin is not loading

    did you have the sqldrivers directory in the mypath directory?
    PS. the sqldrivers directory must have needed sql drivers.

  8. #8
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ODBC Database plugin is not loading

    Yes, I did. Each of the directories that QApplication::libraryPaths() returns have
    plugins\sqldrivers construct in them. In other words these directories look like:
    <mypath>\plugins\sqldrivers
    <QTpath>\plugins\sqldrivers
    <apppath>\plugins\sqldrivers

    Yes, and one other thing: application runs under VC2008 debugger, started from VS2008 IDE.

  9. #9
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: ODBC Database plugin is not loading

    and you run debug version of you program and sqldrivers have debug pugins?

  10. #10
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ODBC Database plugin is not loading

    This is the contents of the directory that all three directories have:

    Directory of <path>\plugins\sqldrivers

    11/04/2008 09:11 AM <DIR> .
    11/04/2008 09:11 AM <DIR> ..
    12/08/2006 04:36 PM 37,376 dwmapi.dll
    01/24/2004 03:17 AM 25,088 efsadu.dll
    08/04/2004 09:56 AM 59,904 mpr.dll
    11/07/2007 12:19 AM 655,872 msvcr90.dll
    11/07/2007 12:19 AM 1,180,672 msvcr90d.dll
    11/03/2008 09:13 AM 71,680 qsqlodbc4.dll
    11/03/2008 09:13 AM 134,656 qsqlodbcd4.dll

  11. #11
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: ODBC Database plugin is not loading

    these two files must be in sqldrivers directory
    11/03/2008 09:13 AM 71,680 qsqlodbc4.dll
    11/03/2008 09:13 AM 134,656 qsqlodbcd4.dll
    i.e. the structure of you directory must be
    yourappdir
    |---sqldrivers
    | |---qsqlodbc4.dll
    | |---qsqlodbcd4.dll
    |---yourapp.exe
    Last edited by spirit; 4th November 2008 at 14:33. Reason: reformatted to look better

  12. The following user says thank you to spirit for this useful post:

    QPlace (4th November 2008)

  13. #12
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ODBC Database plugin is not loading

    Thank you, that was the problem. So, it is not "plugins/sqldrivers", but "sqldrivers"...

Similar Threads

  1. ODBC Oracle. Unable to connect to database
    By egil in forum Qt Programming
    Replies: 2
    Last Post: 17th October 2008, 13:46
  2. problem loading custom plugin on Qt Designer 4
    By raman_31181 in forum Qt Tools
    Replies: 18
    Last Post: 26th September 2008, 09:42
  3. How to debug plugin loading?
    By yosefm in forum Qt Tools
    Replies: 1
    Last Post: 1st November 2007, 12:02
  4. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 14:13
  5. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 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.