FOUND A SOLUTION:
on Ubuntu Server I needed to install some packages
Code:
sudo aptitude install unixodbc unixodbc-dev freetds-dev sqsh tdsodbc
With FreeTDS installed I could configure it like this:
Code:
/etc $ cat freetds.conf
[SERVER]
host = 192.168.0.10
port = 1433
tds version = 7.0
The important thing here is SERVER, which is the DSN that I’ll use when connecting to the database. The host, and port are self-explanatory, and it’s worth nothing that I had to use 7.0 specifically as the tds version.
Testing FreeTDS is not too hard:
Code:
$ sqsh -S SERVER -U username -P password
sqsh: Symbol `_XmStrings' has different size in shared object, consider re-linking
sqsh-2.1 Copyright (C) 1995-2001 Scott C. Gray
This is free software with ABSOLUTELY NO WARRANTY
For more information type '\warranty'
1> use test
2> go
1> select top 1 firstname, lastname from tblClients
2> go
[record returned]
(1 row affected)
1> quit
Next up it’s necessary to configure ODBC:
Code:
/etc$ cat odbcinst.ini
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
CPTimeout =
CPReuse =
FileUsage = 1
/etc$ cat odbc.ini
[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = No
Servername = SERVER
Database = DATABASE
I then tested the connection with isql:
Code:
$ isql -v SERVER username password
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> use DATABASE
[][unixODBC][FreeTDS][SQL Server]Changed database context to 'database'.
[ISQL]INFO: SQLExecute returned SQL_SUCCESS_WITH_INFO
SQLRowCount returns -1
SQL> select top 1 firstname from tblClients;
[record returned]
SQLRowCount returns 1
1 rows fetched
SQL> quit
OK, so we’ve got ODBC using FreeTDS to connect to a remote MSSQL server.
Bye,
Fabio Casolari
http://www.ripartodazero.it
Bookmarks