You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var DataTable = function (opts) {
this.columns = [];
for (key in opts) {
if (opts.hasOwnProperty(key)) {
// this.columns.push (opts[key]);
this.columns.push (opts[key]);
}
}
this.rows = [];
this.currentRowNo = null;
}
DataTable.prototype.addRow = function (idx) {
this.rows.push ({});
this.currentRowNo = idx;
}
DataTable.prototype.addDataToRow = function (idx, data) {
this.rows[this.currentRowNo][this.columns[idx].name] = data;
}
Use with Current Evented Query function
varsql=require('msnodesql')varconn_str="Driver={SQL Server Native Client 10.0};Server=(local);Database={TestDB};Trusted_Connection={Yes};";vardt;varstmt=sql.query(conn_str,"SELECT * from tbl1");stmt.on('meta',function(meta){dt=newDataTable(meta);});stmt.on('row',function(idx){dt.addRow(idx);});stmt.on('column',function(idx,data,more){dt.addDataToRow(idx,data);});stmt.on('done',function(){console.log(dt);for(drindt.rows){console.log('dr: ',dt.rows[dr]["value"]);}});stmt.on('error',function(err){console.log("We had an error :-( "+err);});