无法使用 Tedious 和 Node JS 连接到本地 SQL 服务器数据库
Failed to connect to local SQL Server database using Tedious and Node JS
我正在尝试连接到我本地计算机上的 SQL 服务器。我正在尝试使用乏味和乏味的 ntlm。两者的配置如下:
var tds = require("tedious-ntlm");
//var tds = require("tedious");
var config = {
userName: 'pratikdb',
password: 'pratikdb',
server: '.',
options: {
database: "TEST",
debug: {
packet: false,
payload: false,
token: false,
data: false
},
encrypt: true
}
};
http.createServer(app).listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
var connection = new tds.Connection(config);
connection.on('connect', function (err) {
console.log(err);
});
});
当我处理 tedious 时,出现此错误:
ConnectionError: Failed to connect to .:1433 - getaddrinfo ENOTFOUND . .:1433]
message: 'Failed to connect to .:1433 - getaddrinfo ENOTFOUND . .:1433', code: 'ESOCKET'
当我使用 "tedious-ntlm" 时,出现此错误:
Connection to .:1433 - failed Error: getaddrinfo ENOTFOUND . .:1433
如前所述here,我尝试使用机器的 ip,但我遇到了同样的错误。
编辑:
当我按照@jmugz3 的建议修改如下配置时:
var config = {
userName: 'pratikdb',
password: 'pratikdb',
server: 'DELL',
options: {
instanceName: ".",
database: "TEST",
debug: {
packet: false,
payload: false,
token: false,
data: false
},
encrypt: true
}
};
我遇到错误:
Error: Port for . not found in ServerName;DELL;InstanceName;MSSQLSERVER;IsClustered;No;Version;11.0.2100.60;tcp;1433;np;\DELL\pipe\sql\query;;
谁能帮帮我?
提前致谢。
找到答案tedious discussion。将我的配置变量更改为
var sqlConfig = {
userName: 'pratikdb', //username created from SQL Management Studio
password: 'pratikdb',
server: 'DELL', //the IP of the machine where SQL Server runs
options: {
instanceName: 'MSSQLSERVER',
database: 'Test', //the username above should have granted permissions in order to access this DB.
debug: {
packet: false,
payload: false,
token: false,
data: false
},
//encrypt: true
}
};
要查找的要点是 server 和 instanceName 的大写。出于某种原因,乏味的是在数组的键和值中保持区分大小写。
我正在尝试连接到我本地计算机上的 SQL 服务器。我正在尝试使用乏味和乏味的 ntlm。两者的配置如下:
var tds = require("tedious-ntlm");
//var tds = require("tedious");
var config = {
userName: 'pratikdb',
password: 'pratikdb',
server: '.',
options: {
database: "TEST",
debug: {
packet: false,
payload: false,
token: false,
data: false
},
encrypt: true
}
};
http.createServer(app).listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
var connection = new tds.Connection(config);
connection.on('connect', function (err) {
console.log(err);
});
});
当我处理 tedious 时,出现此错误:
ConnectionError: Failed to connect to .:1433 - getaddrinfo ENOTFOUND . .:1433]
message: 'Failed to connect to .:1433 - getaddrinfo ENOTFOUND . .:1433', code: 'ESOCKET'
当我使用 "tedious-ntlm" 时,出现此错误:
Connection to .:1433 - failed Error: getaddrinfo ENOTFOUND . .:1433
如前所述here,我尝试使用机器的 ip,但我遇到了同样的错误。
编辑:
当我按照@jmugz3 的建议修改如下配置时:
var config = {
userName: 'pratikdb',
password: 'pratikdb',
server: 'DELL',
options: {
instanceName: ".",
database: "TEST",
debug: {
packet: false,
payload: false,
token: false,
data: false
},
encrypt: true
}
};
我遇到错误:
Error: Port for . not found in ServerName;DELL;InstanceName;MSSQLSERVER;IsClustered;No;Version;11.0.2100.60;tcp;1433;np;\DELL\pipe\sql\query;;
谁能帮帮我?
提前致谢。
找到答案tedious discussion。将我的配置变量更改为
var sqlConfig = {
userName: 'pratikdb', //username created from SQL Management Studio
password: 'pratikdb',
server: 'DELL', //the IP of the machine where SQL Server runs
options: {
instanceName: 'MSSQLSERVER',
database: 'Test', //the username above should have granted permissions in order to access this DB.
debug: {
packet: false,
payload: false,
token: false,
data: false
},
//encrypt: true
}
};
要查找的要点是 server 和 instanceName 的大写。出于某种原因,乏味的是在数组的键和值中保持区分大小写。