具体错误是:
{ [ConnectionError: Failed to connect to localhost:1433 - connect ECONNREFUSED] name: 'ConnectionError', message: 'Failed to connect to localhost:1433 - connect ECONNREFUSED', code: 'ESOCKET' }
我的代码,主要是按官网上的:
var sql = require('mssql');
var config = {
user: 'sa',
password: '123456',
server: 'localhost', // You can use 'localhost\\instance' to connect to named instance
database: 'expressdb'
};
var connection = new sql.Connection(config);
connection.connect(function(err) {
if(err){
var util = require('util');
var tmp = util.inspect(err);
res.send(tmp);
}else{
res.send("ok");
}
});
大家是否遇到过同样问题,在网上一直接不到答案?
2 回复