title: Nodejs Tedious Mssql Invalid State
body: <p>I have a virtual box running Ubuntu on my local machine. I have installed nodejs as well as tedious the mssql driver. I'm attempting to pull data from a remote mssql server from a query and return json. </p>
  
  <p>I've read through quite a bit of documentation the first question I would just like answered is do you have to run Nodejs on a windows box to connect to mssql server? </p>
  
  <p>(I am under the impression this is the case when using the standards nodejs windows driver.)</p>
  
  <p>The second question I have stepped through all of my process and the node server is functioning fine but when I get to the mssql call I'm getting the following error: </p>
  
  <pre><code>Invalid state; requests can only be made in the LoggedIn state, not the SentLogin7WithStandardLogin state
  </code></pre>
  
  <p>I have not found anyone else that has run into this error with the same situation as myself. I have tried sending the request with the object formation as suggested in this fix. </p>
  
  <p><a href="https://stackoverflow.com/questions/16047905/how-do-i-connect-to-sql-azure-from-nodejs-tedious">How do I connect to SQL Azure from NodeJS/Tedious?</a></p>
  
  <p>I'm still getting the same error as mentioned before. So here is the code. I'm using restify was hoping just to make a restful api our of my nodejs server and spit back json from my mssql calls. </p>
  
  <pre><code>var restify = require('restify');
  var Connection = require('tedious').Connection;
  var server = restify.createServer();
  
  server.listen(8080,function(){
    console.log('%s listening at %s',server.name,server.url);
    server.get('/GetInfo',GetInfo);
  });
  
  function GetInfo(req, res, next){
  
    console.log('Starting GetInfo function ...');
    res.header('Content-Type:application/json');
  
    var config = {
      user:'awesomeusername',
      password:'awesomepassword',
      server:'coolservername',
      options:{
        encrypt:true,
        database:'TableName'
    }
  };
  var connection = new Connection(config);
  var Request = require('tedious').Request;
  
  var sql = "SELECT ColumnName FROM Database.dbo.TableName";
  connection.on('connect',function(err){
    request = new Request(sql,function(err,rowCount){
    if(err){
      res.write(err);  
      console.log('got an error %s',err)
    }else{
       res.write(rowCount+'rows'); 
    }
    });
  
   request.on('row',function(columns){
   columns.forEach(function(column){
   res.write(column.value); 
   });
  
  });
  
  connection.execSql(request);
   });
  
   } 
  </code></pre>
  
  <p>So there you have I'm a complete novice with nodejs I thought I would give it a try. Any tips or information is appreciated. Thanks in advance. </p>