Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 无法使用冗长的和节点JS连接到本地SQL Server数据库_Sql Server_Node.js_Tedious - Fatal编程技术网

Sql server 无法使用冗长的和节点JS连接到本地SQL Server数据库

Sql server 无法使用冗长的和节点JS连接到本地SQL Server数据库,sql-server,node.js,tedious,Sql Server,Node.js,Tedious,我正在尝试连接到本地计算机上的SQL Server。我正在尝试使用单调乏味的ntlm。两者的配置如下所示: var tds = require("tedious-ntlm"); //var tds = require("tedious"); var config = { userName: 'pratikdb', password: 'pratikdb', server: '.', options: { database: "TEST", debug: { pac

我正在尝试连接到本地计算机上的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);
    });
});
当我使用Teduous时,我会遇到以下错误:

ConnectionError:未能连接到。:1433-getaddrinfo ENOTFOUND..:1433]
消息:“未能连接到.:1433-getaddrinfo ENOTFOUND..:1433',代码:“ESOCKET”

当我使用“乏味的ntlm”时,我遇到以下错误:

连接到。:1433-失败错误:getaddrinfo ENOTFOUND..:1433

如前所述,我尝试使用机器的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
    }
};
我得到一个错误:

错误:的端口。在ServerName中找不到;戴尔;实例名;MSSQLSERVER;分散的;不版本11.0.2100.60;tcp;1433;np\DELL\pipe\sql\query

有人能帮我吗

提前感谢。

找到了答案。将我的配置变量更改为

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
    }

};

要查找的要点是服务器和instanceName的大写字母。出于某种原因,冗长的任务是在数组的键和值中保持大小写敏感。

您是否尝试过对localhost使用实际的服务器名而不是(.)呢?@jmugz3我尝试过使用MSSQLServer,如果正确的话。如果没有,你能告诉我如何找到服务器名吗?使用MSSQLServer时,我遇到了相同的错误。登录sql server实例后,请尝试选择@SERVERNAME。@jmugz3,请参阅我对该问题所做的编辑。在为添加instancename:error:Port后,我遇到以下错误。在ServerName中找不到;戴尔;实例名;MSSQLSERVER;分散的;不版本11.0.2100.60;tcp;1433;np\\DELL\pipe\sql\query;;如果没有实例名,我得到的只是“未定义”@sqluser您是对的。当我发布此答案时,连接存在问题。我会尽快更新答案。注释出
//encrypt:true
暂时有效。但是我想如果我能找到一个解决方案使它工作的话,最好使用
encrypt=true