Installing ODBC driver on Ubuntu getting syntax error after running "make"
-
wrote on 3 Jan 2017, 18:15 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..
-
Hi and welcome to devnet,
You are likely using the wrong qmake.
Use the full path to your Qt 5.7 qmake.
-
wrote on 3 Jan 2017, 20:17 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 ?
-
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.
-
wrote on 3 Jan 2017, 20:42 last edited by
it says
[unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found QODBC3: Unable to connect
-
What is your connection string ?
-
wrote on 3 Jan 2017, 20:57 last edited by Amir5121 1 Mar 2017, 21:01
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) -
Did you check unixODBC without the GUI ?
-
wrote on 3 Jan 2017, 22:18 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/10