1
Hello, I have an error in the nodejs MSSQL module for SQL Server connections. The connection occurs normal, the problem is time to perform the query, the function does not return me anything in callback.
Connection code:
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;
};
I tried, it just hangs while trying to do the query and does not return me anything in callback
– João Victor
I added a
catch
in my example, try so– Sorack
{ name: 'Connectionerror', message: 'Connection is closed. ', code: 'ECONNCLOSED' } Strange, it is closing the connection
– João Victor
@Joãovictor made one more change, try it like this
– Sorack
I managed to connect, the problem now is that it returns the error: "Could not find stored Procedure’S'"
– João Victor
@Joãovictor made one more change. Check if this works
– Sorack
Gave "Object "Promise" has in method 'query'
– João Victor