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
Sql server 使用NodeJs mssql通过Windows身份验证连接到SQL Server_Sql Server - Fatal编程技术网

Sql server 使用NodeJs mssql通过Windows身份验证连接到SQL Server

Sql server 使用NodeJs mssql通过Windows身份验证连接到SQL Server,sql-server,Sql Server,我需要使用nodeJs连接到SQL Server。这是我通常用于.NET的连接字符串 Data Source=DESKTOP-QPC8N68\SQLEXPRESS;Initial Catalog=ProjectX;Integrated Security=True 我使用的是mssqlnpm包,我的代码如下: app.get('/', function (req, res) { var sql = require("mssql"); var config = {

我需要使用nodeJs连接到SQL Server。这是我通常用于.NET的连接字符串

Data Source=DESKTOP-QPC8N68\SQLEXPRESS;Initial Catalog=ProjectX;Integrated Security=True
我使用的是
mssql
npm包,我的代码如下:

app.get('/', function (req, res) {
    var sql = require("mssql");

    var config = {
        server: 'localhost\\SQLEXPRESS',
        database: 'ProjectX',

        options: {
            trustedConnection: true
        }
    };

    sql.connect(config).then(function (ar) {
        console.log('connected');
        console.log(ar);
    }).catch(function (ex) {
        console.log(ex);
    });

    res.send('OK');
});
我得到以下错误

ConnectionError:无法连接到本地主机:在15000ms内未定义
在连接处。(C:\Drive F\NodeSql\node\u modules\mssql\lib\tedious.js:378:25)
名称:“ConnectionError”,
消息:“未能连接到本地主机:15000ms内未定义”,
代码:“ETIMEOUT”

ConnectionError:无法连接到本地主机:在15000ms内未定义
在连接处。
在ontimeout(timers.js:365:14)
在tryOnTimeout(timers.js:237:5) 在Timer.listOnTimeout(timers.js:207:5)
名称:“ConnectionError”,
消息:“未能连接到本地主机:15000ms内未定义”,
代码:“ETIMEOUT”


我正在使用Windows身份验证连接到SQL Server。这里缺少什么,您建议连接到SQL Server的npm包是什么

有人能帮上忙吗?有人能帮上忙吗?有人能帮上忙吗