title: Request Data from MSSQL with Node.js -- Error
body: <p>I want to connect and Request from MSSQL using nodejs to link it with magento.
  I Am trying to fix it for days now but it ends on the same way...</p>
  
  <p>This is my Error Code:</p>
  
  <pre><code>Connected
  { RequestError: Requests can only be made in the LoggedIn state, not the Connecting state
  at RequestError (C:\Workspace\Visual-Code\nodeApi\node_modules\tedious\lib\errors.js:34:12)
  at Connection.makeRequest (C:\Workspace\Visual-Code\nodeApi\node_modules\tedious\lib\connection.js:1423:33)
  at Connection.execSql (C:\Workspace\Visual-Code\nodeApi\node_modules\tedious\lib\connection.js:1194:19)
  at executeStatement (C:\Workspace\Visual-Code\nodeApi\nodeapi.js:41:20)
  at Connection.&lt;anonymous&gt; (C:\Workspace\Visual-Code\nodeApi\nodeapi.js:14:9)
  at emitOne (events.js:116:13)
  at Connection.emit (events.js:211:7)
  at Connection.socketError (C:\Workspace\Visual-Code\nodeApi\node_modules\tedious\lib\connection.js:869:14)
  at C:\Workspace\Visual-Code\nodeApi\node_modules\tedious\lib\connection.js:739:25
  at GetAddrInfoReqWrap.callback (C:\Workspace\Visual-Code\nodeApi\node_modules\tedious\lib\connector.js:68:18)
  message: 'Requests can only be made in the LoggedIn state, not the 
  Connecting state',
  code: 'EINVALIDSTATE' }
  </code></pre>
  
  <p>I searched a lot and found similar problems but nothing solved it...
  This is my Code maybe you can help me Spot the mistake.</p>
  
  <pre><code>var Connection = require('tedious').Connection;  
  var config = {  
      userName: 'Cool userName',  
      password: 'awesome password',  
      server: 'amazing server',
      options: {
          database: 'database',
      }  
  };  
  var connection = new Connection(config);  
  connection.on('connect', function(err) {  
      // If no error, then good to proceed.  
      console.log("Connected");  
      executeStatement();  
  });  
  
  var Request = require('tedious').Request;  
  var TYPES = require('tedious').TYPES;  
  
  function executeStatement() {  
      request = new Request("select * from Artikelstamm;", function(err) {  
      if (err) {  
          console.log(err);}  
      });  
      var result = "";  
      request.on('row', function(columns) {  
          columns.forEach(function(column) {  
            if (column.value === null) {  
              console.log('NULL');  
            } else {  
              result+= column.value + " ";  
            }  
          });  
          console.log(result);  
          result ="";  
      });  
  
      request.on('done', function(rowCount, more) {  
      console.log(rowCount + ' rows returned');  
      });  
      connection.execSql(request);
  }  
  </code></pre>