所以这是我正在运行的基本代码块。我让 RowCount 按预期返回(现在只有 5 个项目),但 rows 作为空数组返回。
难道我做错了什么?顺便说一句,我正在连接到 SQL azure。我没有任何连接问题,并且我相信我已经设置了正确的选项(rowCollectionOnRequestCompletion 为 true)。
有任何想法吗?
var Connection = require('tedious').Connection;
var Request = require('tedious').Request;
exports.list = function(req, res){
var connection = new Connection({
"userName": "myCoolUsername",
"password": "SoMePa$$word",
"server": "something.database.windows.net",
"options": {
"database": "mySampleDbName",
"encrypt": true,
"rowCollectionOnDone": true,
"rowCollectionOnRequestCompletion": true
}
});
connection.on('connect', function(err){
//if no error, then we are good to go.
if(err){
console.log(err);
}else
{
var request = new Request("SELECT * FROM Products", function(err, rowCount, rows){
console.log(rowCount);
res.send(rows);
})
connection.execSql(request);
}
});