Naidu K

Naidu K

  • NA
  • 87
  • 20.1k

Calling stored procedure from node js

Mar 1 2021 4:15 AM
I am using express and I am trying to call LoginMember stored procedure from Azure portal. This is my form from, taken from ejs:
  1. <form method="post" action="/available-copies">    
  2.       <input type="text" placeholder="SSN" name="userssn">    
  3.       <input type="password" placeholder="Password" name="userpassword">    
  4.       <input type="submit" value="Login">    
  5. </form>   
This is my post request
  1. router.post('/available-copies'function (req, res) {    
  2.     var ssn = req.body.userssn;    
  3.     var password = req.body.userpassword;    
  4.     
  5.     sql.connect(sqlConfig, function (err) {    
  6.         if (err) console.log(err);    
  7.         // create Request object    
  8.         var request = new sql.Request();    
  9.         // query to the database and execute procedure    
  10.         request.query("exec LoginMember @SSN='"+ssn+"', @PASSWORD='"+password+"';"function (err, recordset) {    
  11.             if (err) console.log(err);    
  12.     
  13.             res.send(recordset);    
  14.         });    
  15.     });    
  16.     sql.close()    
  17. });  
Thanks in advance

Answers (1)