var Connection = require('tedious').Connection;
var Request = require('tedious').Request;
var express = require('express');
// Create connection to database
var config = {
server: "localhost",
userName: 'bassb',
password: '32460101',
//driver: "msnodesqlv14",
options: {
database: "GIBDD",
encrypt: false
}
};
var connection = new Connection(config);
connection.on('connect', function (err) {
if (err) {
console.log(err);
}
else {
queryDatabase();
}
}
)
//в этой функции я делаю select таблицы и вон,
//где "request.on" вывожу в консоль, а мне надо выводить на страницу!
function queryDatabase() {
request = new Request("SELECT * FROM officers", function (err, rowCount, rows) {
console.log(rowCount + ' row(s) returned');
//process.exit();
});
request.on('row', function (columns) {
columns.forEach(function (column) {
console.log("%s\t%s", column.metadata.colName, column.value);
colOfficer.push(column.metadata.colName);
valOfficer.push(column.value);
});
});
connection.execSql(request);
}