These instructions come from many other websites and I have consolidated them for what has worked for me. If this also works for you, then that’s a good thing. I have used these instructions to setup ODBC connectivity from Ubuntu 16.04 to a MSSQL server running 2008r2. Then I have written applications using this ODBC connection in Gambas.
Install Required Packages
sudo apt-get install unixodbc unixodbc-dev freetds-bin
Download and Compile FreeTDS
cd /usr/local
sudo
wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
tar xvfz freetds-stable.tgz
cd freetds-0.82
./configure --enable-msdblib --with-tdsver=8.0 --with-unixodbc=/usr
make
make install
make clean
Test Connections
telnet <ip address of SQL Server> 1433
Should result in:
Connected to <ip address of SQL Server>
tsql -S <ip address of SQL Server> -U <username>
Should result in:
1>
Create Configuration File
In the home directory create .odbc.ini –
[mssqlserver] Description = MS SQL Server Driver = /usr/local/lib/libtdsodbc.so Server = <ip address of SQL Server> UID = <username> PWD = <password> ReadOnly = No Port = 1433 TDS_Version = 8.0
Test ODBC Connection
isql -v mssqlserver <username> ‘<password>’