I was wondering how to I select a specific column to save to a variable in my function. I need both values which is why I have a query getting both at once. I'm using Node JS with an Azure SQL Database and I'm using tedious for my SQL NPM plugin. I'm fairly new to this so any help would be appreciated. Thanks!
Side note: the request "on done" at the very bottom that returns the row count isn't doing anything. If anyone knows why I'd love to know, it's not important but I'm just curious.
function Charge(chipId, LocID) {
request = new Request("SELECT car_id, userOwner FROM Cars WHERE carChipId = '" + chipId + "'", 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);
}