How to get the return of an sql query using nodejs

Asked

Viewed 369 times

1

Good afternoon, I’m venturing into nodejs and I’m doing some pranks and I’m having a hard time getting the return of an sql query. I found some examples on the internet and even work (the result is on the console), and it’s not what I expected... I would like to get as a list or anything else, how can I do this?

Note: I have no knowledge of javascript

code:

var sql = require("mssql");
function queryinfo (info) {
 // Create connection instance
  var conn = new sql.ConnectionPool(dbConfig);
  conn.connect()
 // Successfull connection
 .then(function () {
   // Create request instance, passing in connection instance
   var req = new sql.Request(conn);
   var content = {};
   // Call mssql's query method passing in params
   req.query("SELECT info, consulta FROM dbo.infoconsulta WHERE info=\'" + info + "\'")
   .then(function (recordset) {      
    return recordset;
    })
   // Handle sql statement execution errors
   .catch(function (err) {
     console.log(err);
     conn.close();
   })

 })
}
  • 1

    What do you want to do with the comic book data? You have a request pending for reply? can explain that part better?

  • What do you mean? Waiting for an answer? can yes, I’m playing with the bot-framework from microsoft, I hope to consult the information and use in the return message for the user expected to access it something like result[0] = basic info, result[1] = something else

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.