[freetds] Issue with Connecting to MS SQL

Oswin Dsa Oswin.Dsa at mindtree.com
Mon Mar 28 02:07:57 EDT 2016


I'm trying to connect to Microsoft SQL Server from my Mac application using iODBC and FreeTDS. No matter what I do, I get the error message "Unable to connect to data source" from the FreeTDS driver. I have consulted as many possible manuals, blog posts, and StackOverflow questions.

Following is the troubleshooting steps I tried and more details about my code,

DB Connection string = Driver=/Applications/xxx.app/Contents/Frameworks/libtdsodbc.so;Server=ip;DATABASE=DB;TDS_Version=8.0;Port=1433;ClientCharset=UTF-8;uid=username;pwd=*****;Trusted_Connection=No;

>From application logs,

SQLGetDiagRec function returns

[01000] [FreeTDS][SQL Server]Adaptive Server connection failed (20002)

[08001] [FreeTDS][SQL Server]Unable to connect to data source (0)

Few StackOverflow post's suggested this is due to TDS version and changing to 8.0 would help but it's already set.

When I ping the server - no packets are lost. Connection is established when I telnet the server on 1433 port.

Using the below I am able to establish connection too,

tsql -H >IP< -p 1433 -U username -P password

Few searches online I found that if SERVER attribute is used in connection string then freetds.config and odbc.ini are ignored. So I guess the config file parameters don't help much.

Also to add a point this works for most of the environment expect a few,  is there any way to find why those few are not able to connect ?

Could anyone please provide me with some pointers or any help so I can proceed further.





More information about the FreeTDS mailing list