gfosco/tsqlftw — Issue #4: Two queries on the same connectoin
Author: muellerkyle
Created: 2012-02-24 15:57:00+00:00
State: open

First, I'd like to say thank you for your library!

But, I've run into a bit of an issue and unfortunately I'm not familiar with building modules in c++ for node, so I'm having a hard time deciphering what is occurring.

I've attempted to run two queries using your library on the same connection, but I'm not able to get the second query to execute without throwing an exception.

Sample JS code:

var db = require('./tsqlftw').tsqlftw,
mssql = new db();

var c = "SELECT Count(*) As count FROM TableA",
q = "SELECT * FROM TableA",
recSet = {
total: 0,
rows: []
}

mssql.connect('ConnString',
function(err,data) {
mssql.query(c,function(err,cResults) {
var rc = JSON.parse(cResults)
recSet.total = rc.rows["0"].Count;
mssql.query(q,function(err,qResults) {
var i,
d = JSON.parse(results);
for (i in d.rows) {
recSet.rows.push(d.rows[i]);
}
mssql.close(function() { } );
});
})
}
);

------------------------------------------

I hand typed the code above, so it may not compile directly, but I hope it conveys the scenario.

I'm able to get either query to run independently, but now when chained. I thought that you might be automatically closing the Database connection after the initial query, but I'm unable to find that in your code.

Did I miss something?