小编Bri*_*tta的帖子

Node.js 与 SQL Server Windows 身份验证的连接

我试图连接node.js到mssql在Windows身份验证模式。我安装了tedious,mssql和msnodesqlv8模块,但我仍然不知道如何打开连接。

这是我尝试过的:

    var sql = require('mssql');
    var config = {
    driver: 'msnodesqlv8',
    server: 'POPPY-GI\\SQLEXPRESS',
    database: 'NodinSports',
    options:{
    trustedConnection: true,
    useUTC: true}}

    sql.connect(config).then(function() { 
    new sql.Request().query('select * from users')
    .then(function(recordset){
    console.log(recordset);
    }).catch(function(err) {
    console.log(err);});
    }).catch(function(err) {
    console.log(err);});
Run Code Online (Sandbox Code Playgroud)

运行后,我收到一个很长的错误消息:

    `ConnectionError`: Port for `SQLEXPRESS` not found in 
 `ServerName`;POPPYGI;`InstanceName;SQLEXPRESS;IsClustered`;No;Version;12.0.2000.8;;

    at Connection.tedious.once.err (D:\Never Lazy\University\`AN2, SEM 2\WEB\`Projek`\node_modules\`mssql`\lib\`tedious.js:216:17`)

    at Connection.g (events.js:291:16)
    at emitOne (events.js:96:13)
    at Connection.emit (events.js:188:7)
    at D:\Never Lazy\University\AN2,SEM2\WEB\Projekt\node_modules\tedious\lib\connection.js:570:27
    at D:\Never Lazy\University\AN2,SEM2\WEB\Projekt\node_modules\tedious\lib\instance-lookup.js:91:24
    at Socket.onMessage (D:\Never Lazy\University\AN2,SEM2\WEB\Projekt\node_modules\tedious\lib\sender.js:140:9) …
Run Code Online (Sandbox Code Playgroud)

sql-server windows-authentication node.js npm

5
推荐指数
1
解决办法
7364
查看次数

标签 统计

node.js ×1

npm ×1

sql-server ×1

windows-authentication ×1