首页 文章

无法使用Node.js连接到SQL Server Express

提问于
浏览
0

我目前正在尝试使用以下节点程序 app.js Build 与本地计算机上的SQL Server实例的连接:

var sql = require('mssql');

sql.connect("mssql://sa:temp2@localhost/Northwind").then(function() {
    // Query 

    new sql.Request().query('select * from TableName').then(function(recordset) {
        console.dir(recordset);
    }).catch(function(err) {
        console.log(err);
    });

}).catch(function(err) {
    console.log(err);
});

而错误:

{ConnectionError:无法连接到localhost:1433 - 在Connection连接ECONNREFUSED 127.0.0.1:1433 . (C:\ Users \ name \ nodeprac \ node_modules \ mssql \ lib \ tedious.js:378:25)在Connection的连接点(events.js:286:16)处于emitOne(events.js:96:13)位于emit.sne的Connection.socketError(C:\ Users \ name \ nodeprac \ node_modules \ tedious \ lib \ connection.js:531:14)中的.emit(events.js:188:7)(events.js:96:13)在Socket.emit(events.js:188:7)的emitErrorNT(net.js:1272:8),在process._tickCallback(internal / process / next_tick)的_combinedTickCallback(internal / process / next_tick.js:74:11) . js:98:9)name:'ConnectionError',message:'无法连接到localhost:1433 - 连接ECONNREFUSED 127.0.0.1:1433',代码:'ESOCKET'}

我've tried a million other ways of establishing a connection with other errors, but I feel like there must be something simple here that I am missing. Also, there is more than one instance of SQLServer Express on my machine. Would removing one help? I' ve为当前服务器启用了所有 TCP/IP 端口,并将所有端口设置为 1433

任何建议将非常感谢 .

1 回答

  • 0

    需要重新启动我的系统(就像我洗刷一样) . 现在工作 . 除非重新启动系统(SQL Server配置管理器试图告诉我),否则启用TCP / IP的更改不会生效 .

相关问题