Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Installing ODBC driver on Ubuntu getting syntax error after running "make"

    General and Desktop
    odbc driver make sql server unixobdc
    2
    10
    6011
    Loading More Posts
    • 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.
    • A
      Amir5121 last edited by

      I'm trying to install ODBC driver to access a SQL Server Database.. After following the docs here and installing unixODBC from here

      after running

      cd $QTDIR/src/plugins/sqldrivers/odbc
      qmake "INCLUDEPATH+=/usr/local/unixODBC/include" "LIBS+=-L/usr/local/unixODBC/lib -lodbc"
      make
      

      I got a lot of syntax errors

      and still getting

      QSqlDatabase: QODBC driver not loaded
      QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 
      

      when running my code..

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        You are likely using the wrong qmake.

        Use the full path to your Qt 5.7 qmake.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 1
        • A
          Amir5121 last edited by

          Hi. thanks for the welcome and answer.. i was about to install Windows tbh

          and wow. apparently that was the issue now it compiled.. after that i was getting the same error

          QSqlDatabase: QODBC driver not loaded
          QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
          

          but managed to fix it by copy and pasting the compiled "libqsqlodbc.so" file to

          /home/amir/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers
          

          and

          /home/amir/Qt5.7.0/Tools/QtCreator/lib/Qt/plugins/sqldrivers
          

          but i am failing to open my connection. how can make sure it's working ?

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            The open method returns a boolean value so you should check that and if false is returned then you should print the content returned by lastError.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 1
            • A
              Amir5121 last edited by

              it says

              [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found QODBC3: Unable to connect
              
              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                What is your connection string ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 1
                • A
                  Amir5121 last edited by Amir5121

                  DRIVER={SQL Server};Server=localhost\SQLEXPRESS;Database=honar;Uid=SA;Pwd=*******;

                  and i'm using
                  Microsoft SQL Server vNext (CTP1.1) - 14.0.100.187 (X64)
                  Dec 10 2016 02:51:11
                  Copyright (C) 2016 Microsoft Corporation. All rights reserved.
                  on Linux (Ubuntu 16.04.1 LTS)

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    Did you check unixODBC without the GUI ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply Reply Quote 1
                    • A
                      Amir5121 last edited by

                      Dude you are awesome.. that error is solved but yet exist another one..

                      Failed "[unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: Error code 0x2AF9 [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Invalid connection string attribute QODBC3: Unable to connect"
                      

                      and this is the content of odbc.ini

                      [ODBC Driver 13 for SQL Server]
                      Description         = Microsoft ODBC Driver 13 for SQL Server
                      Driver              = /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.1.0
                      Trace               = Yes
                      TraceFile           = sql.log
                      Database            = 
                      Servername          = localhost
                      UserName            = 
                      Password            = 
                      Port                = 1433
                      Protocol            = 6.4
                      ReadOnly            = No
                      RowVersioning       = No
                      ShowSystemTables    = No
                      ShowOidColumn       = No
                      FakeOidIndex        = No
                      ConnSettings        =
                      

                      and odbcinst.ini

                      [ODBC Driver 13 for SQL Server]
                      Description=Microsoft ODBC Driver 13 for SQL Server
                      Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.1.0
                      Setup=/usr/local/lib/libodbc.so.2.0.0
                      UsageCount=1
                      
                      1 Reply Last reply Reply Quote 0
                      • A
                        Amir5121 last edited by

                        @SGaist Thanks for your help.. it's successfuly got connected finally.. i changed localhost\sqlexpress to localhost and it got connected.. what ever sqlexpress is there for. Thanks again

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post