title: "ConnectionError: Already connecting to database! Call close before connecting to different database" connecting SQL server with nodejs
body: <p>Below is the code i am using ,Some times it does not enter .then (function() ,Please let me know how to close the existing connection , I have tried various options like conn.close() after connecting, but it still dint work.</p>
  
  <pre><code>var sql = require("C:/Protractor_Scripts/node_modules/mssql");
  
  function getEmp() {
      console.log('results'); 
      var conn = new sql.Connection("Server=, 1433;Database=;User Id=;Password=;Encrypt=true");
      console.log(conn); 
      console.log(conn.connect());
      conn.connect().then(function () { 
          console.log(conn.connect()); 
          var req = new sql.Request(conn); 
          req.query("select * from").then(function (recordset) {
              console.log(recordset);   
              conn.close();
          }).catch(function (err) {
              console.log(err);   
              conn.close();
          }); 
      }).catch(function (err) {
          console.log(err);  
      });
  }
  
  getEmp();
  </code></pre>
  
  <p>Below is the full error message</p>
  
  <p>[ConnectionError: Already connecting to database! Call close before connecting to different database.]</p>
  
  <pre><code>  name: 'ConnectionError',
  </code></pre>
  
  <p>message: 'Already connecting to database! Call close before connecting to
  different database.',</p>
  
  <pre><code>  code: 'EALREADYCONNECTING' }
  </code></pre>