我尝试在我的SQL Server上进行查询,连接正常,并在更改密码时出现错误。 "错误"在request.query(sql,callback)上,此函数未返回回调
连接代码:
var sql = require('mssql');
var config = {
user: 'user',
password: 'password',
server: 'ip',
database: 'database',
connectionTimeout: '5000',
requestTimeout: '5000',
options: {encrypt: true}
};
var pool = function(){
var conn = new sql.Connection(config, function(err){
var request = new sql.Request(conn);
//console.dir(request);
return request;
});
return conn;
}
module.exports = function(){
return pool;
}
DAO:
function CampanhaDAO(connection){
this._connection = connection;
//console.log(this._connection)
}
CampanhaDAO.prototype.getCampanhas = function(){
var sql = "SELECT * FROM notificacao_campanha";
this._connection.query(sql, function(err, recordset){
console.log(recordset);
});
};
module.exports = function(){
return CampanhaDAO;
};
控制器:
module.exports.campanhas = function(app, req, res){
var connection = app.config.dbConnection();
var campanhaDAO = new app.dao.CampanhaDAO(connection);
campanhaDAO.getCampanhas(function(error, result){
console.log("gerou");
res.send(result);
});
}
任何人都可以帮助我吗?