测试文件如下:
function ConnectDB() {
var config = {
user: 'User',
password: 'password',
server: 'server name',
database: 'dbname',
options: {
encrypt: true
}
};
var connection = new sql.ConnectionPool(config)
connection.connect(function (err) {
console.log(err)
});
var request = new sql.Request(connection);
request.query('select * from dbo.User_Tracking_Info', function (err, recordset) {
var res = recordset;
console.log(res)
});
}
})
它为我提供了undefined: 在这种情况下,Recordset没有值,它显示为undefined。