还是ubuntu 下连接sqlserver,虽然链接问题解决了,但是又遇到编码问题,中文都是乱码
node.js里用到是node-odbc,通过freetds+unixodbc连接sqlserver
Database=require('odbc').Database,
db=new Database(),
cn="DSN=SERVER;UID=sa;PWD=pwd;DATABASE=db",
iconv=require('iconv-lite');
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/html;charset=utf-8"});
db.open(cn,function(err){
if(err) return console.log(err);
db.query("select top 20 usernc from theuser order by userid desc",function(err,rows,moreResultSets){
if(err) return console.log(err);
var a="";
for (var i in rows) {
a+=rows[i].usernc+',';
console.log(rows[i].usernc);
}
response.write(a);
});
db.close(function (err) {
console.log("the database connection is now closed");
});
});
输出到中文都是???????问号,
而直接用isql -v server sa pwd 查出来到中文能正常显示 用tsql -S server -p 1433 -U sa -P pwd 查出来到也没事,
就用node-odbc 出来的是??????