Results 1 to 2 of 2

Thread: QSqlDatabase: QODBC driver not loaded

  1. #1
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QSqlDatabase: QODBC driver not loaded

    hi everyone ,
    I want to connect remotely to ms sql server through an application.For this ODBC is required.
    I followed the following lines:

    Qt Code:
    1. It is recommended that you use unixODBC. You can find the latest version and ODBC drivers at http://www.unixodbc.org. You need the unixODBC header files and shared libraries.
    2.  
    3. Tell qmake where to find the unixODBC header files and shared libraries (here it is assumed that unixODBC is installed in /usr/local/unixODBC) and run make:
    4.  
    5. cd $QTDIR/src/plugins/sqldrivers/odbc
    6. qmake "INCLUDEPATH+=/usr/local/unixODBC/include" "LIBS+=-L/usr/local/unixODBC/lib -lodbc"
    7. make
    To copy to clipboard, switch view to plain text mode 


    But i am getting an error :- QSqlDatabase: QODBC driver not loaded

    My pc is linux 64 bit (fedora -11).I am using qt 4.6.


    My code is :


    Qt Code:
    1. QString conn = QString::fromLocal8Bit("DRIVER={SQL SERVER};SERVER=192.168.10.82\\SQLExpress;DATABASE=master;Uid=sa;Pwd=[]");
    2. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "MainDBConnection");
    3. db.setDatabaseName(conn);
    4. db.setUserName("essl");
    5. db.setPassword("essl");
    6. bool flag = db.open();
    To copy to clipboard, switch view to plain text mode 


    plz tell me how to connect with server .
    Is there anything extra to add plugin .
    or a odbc driver is required

  2. #2
    Join Date
    Sep 2010
    Posts
    14
    Thanks
    5

    Default Re: QSqlDatabase: QODBC driver not loaded

    It is recommended that you use unixODBC. You can find the latest version and ODBC drivers at http://www.unixodbc.org. You need the unixODBC header files and shared libraries.

    Tell qmake where to find the unixODBC header files and shared libraries (here it is assumed that unixODBC is installed in /usr/local/unixODBC) and run make:

    cd $QTDIR/src/plugins/sqldrivers/odbc
    qmake "INCLUDEPATH+=/usr/local/unixODBC/include" "LIBS+=-L/usr/local/unixODBC/lib -lodbc"
    make
    Did you build the plugin successfully? If not you can open it as a normal Qt Project (File->Open File or Project) and you can find the .pro in $QTDIR/src/plugins/sqldrivers/odbc as stated.

    But i am getting an error :- QSqlDatabase: QODBC driver not loaded
    Is there a second line to the error, something like

    Qt Code:
    1. Available drivers are: ...
    To copy to clipboard, switch view to plain text mode 

    If ODBC is in the list of available plugins then the problem is because the unixODBC driver is not installed or set up correctly. On the other hand if the ODBC driver is not in the list then it means that either you haven't built the plugin properly or your application isn't finding it. I had the latter problem with the IBASE plugin which was solved by setting the following environment variable in the project's build environment:

    Qt Code:
    1. Set QT_PLUGIN_PATH to /home/xxxx/qtsdk-2010.04/qt/plugins/
    To copy to clipboard, switch view to plain text mode 

    This is because (on openSuSE at least) the QT_PLUGIN_PATH is set to somewhere in the users .kde folder

    This will get you up and running, but of course you need to do something smarter when it comes to distributing your application
    Last edited by certqt; 22nd January 2011 at 12:45.

Similar Threads

  1. QSqlDatabase: QMYSQL driver not loaded
    By onder in forum Newbie
    Replies: 12
    Last Post: 29th March 2017, 15:43
  2. QSqlDatabase: QODBC driver not loaded
    By gutiory in forum Qt Programming
    Replies: 1
    Last Post: 14th April 2010, 10:24
  3. QODBC driver not loaded error
    By Askar in forum Qt Programming
    Replies: 0
    Last Post: 23rd October 2009, 11:35
  4. Replies: 6
    Last Post: 28th April 2009, 07:58
  5. qodbc driver not loaded error in release mode
    By mandal in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2006, 10:42

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.