-----------第一种方式可以连接----------- var sql = require(‘mssql’); sql.connect(“mssql://sa:123456@localhost/admanager”).then(function() { // Query new sql.Request().query(‘select * from XRuserSet’).then(function(recordset) { console.dir(recordset); }).catch(function(err) { // … query error checks }); }).catch(function(err) { // … connect error checks });
-----------第二种方式为什么不行?-------------------- var sql = require(‘mssql’);
var config = { user: ‘sa’, password: ‘123456’, server: ‘localhost’, // You can use ‘localhost\instance’ to connect to named instance database: ‘admanager’,
options: {
encrypt: true // Use this if you're on Windows Azure
}
}
sql.connect(config, function(err) { var request = new sql.Request(); request.query(‘select * from XRuserSet’, function(err, recordset) { console.dir(recordset); }); }); sql.on(‘error’, function(err) { });
–报错 { [ConnectionError: Failed to connect to 10.81.36.167:1433 in 15000ms] name: ‘ConnectionError’, message: ‘Failed to connect to 10.81.36.167:1433 in 15000ms’, code: ‘ETIMEOUT’ }
** 求高手帮忙**