Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QODBC driver not loaded
Forum Updated to NodeBB v4.3 + New Features

QODBC driver not loaded

Scheduled Pinned Locked Moved General and Desktop
32 Posts 4 Posters 20.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zidom
    wrote on last edited by
    #19

    Hi
    i made some changes
    then i could connect to database
    @#include <QCoreApplication>
    #include <QtSql>
    #include <QDebug>
    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setHostName("LOCALHOST\SQLEXPRESS");
    db.setDatabaseName("mydsn32");
    if(db.open())
    {
    qDebug() << "Opened";
    db.close();
    }
    else
    {
    qDebug() <<"Error = "<<db.lastError();
    }
    return a.exec();
    }
    @
    i made a dsn and i used QSQLITE but i can not still use QODBC but its better than nothing

    1 Reply Last reply
    0
    • T Offline
      T Offline
      terenty
      wrote on last edited by
      #20

      Theres probably some issues with ODBC drivers on your OS

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hardcodes.de
        wrote on last edited by
        #21

        Now I found the time to test it on my own.
        System: Windows7, Qt SDK version 1.2.1 with Qt libraries version 4.8.1 (offline installer).

        I've created a test database on a Microsoft SQL Server Express server (which basically means that the database does not run on my development machine).
        With "C:\Windows\SysWOW64\odbcad32.exe" a user DSN was set up using "Sql Server Native Client 10.0".

        Checked connection via ODVC from comandline

        @C:\Users\username>osql -D QtODBCDSN -U qtodbclogin -P passw0rd
        1>
        @

        Ok, that works, now the Qt part.

        @
        #include <QCoreApplication>
        #include <QtSql/QSqlDatabase>
        #include <QtSql/QODBCDriver>
        #include <QtSql/QSqlError>
        #include <QDebug>

        int main(int argc, char *argv[])
        {
        QCoreApplication a(argc, argv);

        qDebug() << QSqlDatabase::drivers();
        
        QSqlDatabase dataBase = QSqlDatabase::addDatabase("QODBC");
        // using the DSN, created with odbcad32.exe here!
        dataBase.setDatabaseName("QtODBCDSN");
        dataBase.setUserName("qtodbclogin");
        dataBase.setPassword("passw0rd");
        
        if(dataBase.open())
        {
            qDebug() << "Database is open.";
            dataBase.close();
        }
        else qDebug() << "Could not open database, error=" &lt;&lt; dataBase.lastError();
        
        return a.exec(&#41;;
        

        }
        @

        Output:
        @
        ("QSQLITE", "QODBC3", "QODBC")
        Database is open.
        @

        Maybe that helps to check, if your system is corrupt:

        @
        Directory of C:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtSql

        25.09.2012 10:48 <DIR> .
        25.09.2012 10:48 <DIR> ..
        25.09.2012 10:48 23 QDB2Driver
        25.09.2012 10:48 23 QDB2Result
        25.09.2012 10:48 25 QIBaseDriver
        25.09.2012 10:48 25 QIBaseResult
        25.09.2012 10:48 25 QMYSQLDriver
        25.09.2012 10:48 25 QMYSQLResult
        25.09.2012 10:48 23 QOCIDriver
        25.09.2012 10:48 23 QOCIResult
        25.09.2012 10:48 24 QODBCDriver
        25.09.2012 10:48 24 QODBCResult
        25.09.2012 10:48 24 QPSQLDriver
        25.09.2012 10:48 24 QPSQLResult
        25.09.2012 10:48 2.964 qsql.h
        25.09.2012 10:48 27 QSqlDatabase
        25.09.2012 10:48 5.496 qsqldatabase.h
        25.09.2012 10:48 25 QSqlDriver
        25.09.2012 10:48 6.475 qsqldriver.h
        25.09.2012 10:48 27 QSqlDriverCreator
        25.09.2012 10:48 27 QSqlDriverCreatorBase
        25.09.2012 10:48 31 QSqlDriverFactoryInterface
        25.09.2012 10:48 31 QSqlDriverPlugin
        25.09.2012 10:48 2.711 qsqldriverplugin.h
        25.09.2012 10:48 24 QSqlError
        25.09.2012 10:48 3.218 qsqlerror.h
        25.09.2012 10:48 24 QSqlField
        25.09.2012 10:48 3.742 qsqlfield.h
        25.09.2012 10:48 24 QSqlIndex
        25.09.2012 10:48 3.179 qsqlindex.h
        25.09.2012 10:48 27 QSQLite2Driver
        25.09.2012 10:48 27 QSQLite2Result
        25.09.2012 10:48 26 QSQLiteDriver
        25.09.2012 10:48 26 QSQLiteResult
        25.09.2012 10:48 24 QSqlQuery
        25.09.2012 10:48 4.206 qsqlquery.h
        25.09.2012 10:48 29 QSqlQueryModel
        25.09.2012 10:48 3.650 qsqlquerymodel.h
        25.09.2012 10:48 25 QSqlRecord
        25.09.2012 10:48 4.026 qsqlrecord.h
        25.09.2012 10:48 39 QSqlRelation
        25.09.2012 10:48 37 QSqlRelationalDelegate
        25.09.2012 10:48 4.594 qsqlrelationaldelegate.h
        25.09.2012 10:48 39 QSqlRelationalTableModel
        25.09.2012 10:48 3.923 qsqlrelationaltablemodel.h
        25.09.2012 10:48 25 QSqlResult
        25.09.2012 10:48 5.050 qsqlresult.h
        25.09.2012 10:48 29 QSqlTableModel
        25.09.2012 10:48 4.699 qsqltablemodel.h
        25.09.2012 10:48 3.868 qsql_db2.h
        25.09.2012 10:48 4.311 qsql_ibase.h
        25.09.2012 10:48 4.318 qsql_mysql.h
        25.09.2012 10:48 4.122 qsql_oci.h
        25.09.2012 10:48 4.570 qsql_odbc.h
        25.09.2012 10:48 4.666 qsql_psql.h
        25.09.2012 10:48 3.886 qsql_sqlite.h
        25.09.2012 10:48 4.025 qsql_sqlite2.h
        25.09.2012 10:48 4.023 qsql_symsql.h
        25.09.2012 10:48 4.089 qsql_tds.h
        25.09.2012 10:48 26 QSymSQLDriver
        25.09.2012 10:48 26 QSymSQLResult
        25.09.2012 10:48 23 QTDSDriver
        25.09.2012 10:48 23 QTDSResult
        25.09.2012 10:48 470 QtSql
        62 File(s) 101.260 bytes
        2 Dir(s) 32.258.682.880 bytes free

        @

        @
        Directory of C:\QtSDK\Desktop\Qt\4.8.1\mingw\plugins\sqldrivers

        25.09.2012 10:49 <DIR> .
        25.09.2012 10:49 <DIR> ..
        25.09.2012 10:49 527.360 qsqlite4.dll
        25.09.2012 10:49 1.872.165 qsqlited4.dll
        25.09.2012 10:49 163.840 qsqlodbc4.dll
        25.09.2012 10:49 997.135 qsqlodbcd4.dll
        4 File(s) 3.560.500 bytes
        2 Dir(s) 32.258.682.880 bytes free
        @

        while(!sleep){++sheep;}

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          zidom
          wrote on last edited by
          #22

          Hi
          thanks for pursuing my problem i have problem in first part
          bq. C:\Users\username>osql -D QtODBCDSN -U qtodbclogin -P passw0rd
          it says
          [ODBC Driver Manager] Data source name not found and no default driver
          specified

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hardcodes.de
            wrote on last edited by
            #23

            Ok, I assume that you inserted your own values for <DSN>, <USERNAME> and <PASSWORD> and not simply entered

            @
            osql -D QtODBCDSN -U qtodbclogin -P passw0rd
            @

            If you use
            @
            C:\Windows\SysWOW64\odbcad32.exe
            @

            again and look into your configured DSN, can you connect to your database from within the Gui (ODBC Data Source Administrator)?

            Have you got "Sql Server Configuration Manager" on our machine? The link in the startmenu goes like "C:\Windows\SysWOW64\mmc.exe /32 C:\Windows\SysWOW64\SQLServerManager10.msc"

            In the left pane there is a menu entry "Sql Server Network Configuration", open that up, click the instance name you're using and make sure that "Named Pipes" is disabled and "TCP/IP" is enabled. That often leads to "I can not connect to server...".

            while(!sleep){++sheep;}

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zidom
              wrote on last edited by
              #24

              i disabled the Named Pipes it was enable and TCP/IP was enable to and in
              C:\Windows\SysWOW64\odbc32.exe my dsn name that i created before is mydsn32 but in authenticity i selected with windows NT authentication using the network login id so i dont need the password and user name then in cmd what should i use for -U and -P?

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hardcodes.de
                wrote on last edited by
                #25

                Omit -U and -P, use -E instead [-E = trusted connection].

                @
                C:\Users\username>osql -?
                Microsoft (R) SQL Server Command Line Tool
                Version 10.50.1600.1 NT x64
                Copyright (c) Microsoft Corporation. All rights reserved.

                Note: osql does not support all features of SQL Server 2008 R2.
                Use sqlcmd instead. See SQL Server Books Online for details.

                usage: osql [-U login id] [-P password]
                [-S server] [-H hostname] [-E trusted connection]
                [-d use database name] [-l login timeout] [-t query timeout]
                [-h headers] [-s colseparator] [-w columnwidth]
                [-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
                [-L list servers] [-c cmdend] [-D ODBC DSN name]
                [-q "cmdline query"] [-Q "cmdline query" and exit]
                [-n remove numbering] [-m errorlevel]
                [-r msgs to stderr] [-V severitylevel]
                [-i inputfile] [-o outputfile]
                [-p print statistics] [-b On error batch abort]
                [-X[1] disable commands [and exit with warning]]
                [-O use Old ISQL behavior disables the following]
                <EOF> batch processing
                Auto console width scaling
                Wide messages
                default errorlevel is -1 vs 1
                [-? show syntax summary]
                @

                while(!sleep){++sheep;}

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  zidom
                  wrote on last edited by
                  #26

                  i used -E Now it says
                  @
                  C:\Users\Zolfaghari>osql -D mydsn32 -E
                  [ODBC Driver Manager] The specified DSN contains an architecture mismatch
                  between the Driver and Application
                  @

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hardcodes.de
                    wrote on last edited by
                    #27

                    "First hit on Google":http://msdn.microsoft.com/en-us/library/windows/desktop/ms712362(v=vs.85).aspx

                    I quote

                    bq. To resolve this error, use the 32-bit odbcad32.exe to configure or remove the DSN.

                    while(!sleep){++sheep;}

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      zidom
                      wrote on last edited by
                      #28

                      yes i read that and fixed the problem with cmd now there is no error in cmd but in qt still says the driver not found my code is same as yours except the user and pass my include and plugin folder are same to

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        hardcodes.de
                        wrote on last edited by
                        #29

                        And you can confirm that you compile a 32 bit program?

                        while(!sleep){++sheep;}

                        1 Reply Last reply
                        0
                        • Z Offline
                          Z Offline
                          zidom
                          wrote on last edited by
                          #30

                          I tried both

                          1 Reply Last reply
                          0
                          • H Offline
                            H Offline
                            hardcodes.de
                            wrote on last edited by
                            #31

                            For the moment I am running out of ideas, sorry.

                            while(!sleep){++sheep;}

                            1 Reply Last reply
                            0
                            • T terenty

                              This is the string that works fine for me:
                              @QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
                              db.setDatabaseName("Driver={SQL Server};DSN='PlaneTraj';SERVER=DB-SERVER;DATABASE=RealPlanesData;");@
                              My user DSN (that I added using C:\Windows\SysWOW64\odbcad32.exe) name is PlaneTraj and its Driver is SQL Server; in your case these are ZiDoM and SQL Server (according to your pic).
                              Try using Driver={SQL Server} instead of yours DRIVER={SQL Native Client}

                              S Offline
                              S Offline
                              Smola
                              wrote on last edited by
                              #32
                              This post is deleted!
                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved