I'm trying to connect from ubuntu (kubuntu 13.04) with nodejs to a sql server db! (sql server 2012) I was looking at node odbc.. so.. I start installing FreeTds, then unixOdbc, then launch: npm install odbc
1) I configured the file "etc/freetds/freetds.conf" like this:
[FreeTDS]
host = gerry_win7
port = 1433
tds_version = 8.0
client charset = UTF-8
2) install sqsh (sudo apt-get install sqsh) and try to connect with
sqsh -S FreeTDS -U trm1 -P user
and execute a query: works perfectly!
3) then, I tried to configure ODBC access in this way: file "/etc/odbcinst.ini":
[FreeTDS]
Description = TDS driver
Driver = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
CPTimeout =
CPReuse =
FileUsage = 1
file "/etc/odbc.ini":
[FreeTDS]
Driver = FreeTDS
Description = ODBC connectin via FreeTDS
Trace = No
Servername = gerry_win7
Database = testsql
UID = trm1
PWD = user
Port = 1433
4) with this sample code with nodejs I received the following error: code:
var cn = 'DRIVER={FreeTDS};SERVER=gerry_win7;UID=trm1;PWD=user;DATABASE=testsql';
var Database = require('odbc').Database, db = new Database();
db.open(cn, function(err){
if (err) {return console.log(err);}
});
error:
[unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[Error: Error opening database]
but, as I wrote before, with the "sqsh" client the connection works: I can run queries! can someone help me understand what I'm doing wrong?
tds_versionbetds versionwith a space?SERVERNAMEinstead ofSERVERin the connection string.