Skip to Content.
Sympa Menu

freetds - Using ODBC on Linux to connect to MS SQL Server

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Jay Miller" <jaymiller AT socket.net>
  • To: <freetds AT franklin.oit.unc.edu>
  • Subject: Using ODBC on Linux to connect to MS SQL Server
  • Date: Mon, 7 Aug 2000 13:37:24 -0500


I am new to this list, so forgive me if this has been answered before.

Has anyone successfully used the FreeTDS ODBC driver under Linux or any
other Unix based system to connect to MS SQL? I have gotten as far as
seeing "Connection refused", which is progress over the "Network
unreachable" that I got before setting the SYBASE environment variable.

I have iODBC 2.50.3 which I am using successfully to connect to MySQL.
Linux kernel version 2.0.x.

Our server is MS SQL Server 2000, running on Windows 2000. I don't actually
know if it uses TDS 7.0 or not. I think that the MS ODBC drivers from
version 7 work with 2000, so I assume the protocol is the same, or at least
backward compatable.

I have installed FreeTDS as follows:

./configure --with-tdsver=70 --enable-msdblib
make
make install
SYBASE=/usr/local/freetds
export SYBASE

My odbc.ini entry is:

[ODBC Data Sources]
accounting = MS SQL Accounting

[accounting]
Trace = ON
Tracefile = stderr
Driver = /usr/local/freetds/lib/libtdsodbc.so
Server = <IP Address of server>
Host = <IP Address of server>
ServerType = SQLServer 7
USER = Employee
PASSWORD = <password>
DATABASE = Accounting
PORT = 1433
DSN = accounting

My interfaces file entry is:

accounting
query tcp ether <IP Address of server> 1433
master tcp ether <IP Address of server> 1433

At this point, I test with iODBC's odbctest program. Here is the output:

OpenLink ODBC Demonstration program
This program shows an interactive SQL processor


Enter ODBC connect string (? shows list): DSN=accounting

SQLAllocEnv ( ... )
SQL_SUCCESS

SQLAllocConnect ( ... )
SQL_SUCCESS

SQLDriverConnect ( ... )
connect: Connection refused
SQL_SUCCESS

SQLGetInfo ( ... )
SQL_SUCCESS

SQLGetInfo ( ... )
SQL_SUCCESS

SQLAllocStmt ( ... )
SQL_SUCCESS


The SQL Server IS running on port 1433. I have it configured to log failed
login attempts, but no failed attempts appear in the log (failed attempts DO
appear when I test with a bad password from a Windows ODBC).

I was able to successfully run src/tds/unittests/t0001 and t0002 after
adding the following lines to the code:

tds_set_port(login, 1433);
tds_set_version(login, 7, 0);

For t0002 I also had to hard code the strings (I haven't tried to debug the
routine that reads PWD). Output from t0002 is:

col 0 is Accounting
col 1 is Employee
tds okay on t0002.c

Curiously, if I leave the "tds_set_port" out, I get a "Connection Refused"
error. Any help on this matter would be appreciated.

Jay Miller
Socket Internet Services
Columbia, MO, US
http://www.socket.net






Archive powered by MHonArc 2.6.24.

Top of Page