gpt4 book ai didi

sql-server - 无法使用 Tedious 和 Node JS 连接到本地 SQL Server 数据库

转载 作者:搜寻专家 更新时间:2023-10-31 23:47:03 33 4
gpt4 key购买 nike

我正在尝试连接到本地计算机上的 SQL Server。我正在尝试使用乏味和乏味的 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-server - 无法使用 Tedious 和 Node JS 连接到本地 SQL Server 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35967238/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com