我已将mssql模块包含在我们的节点配置中。节点的版本是:0.12.0,mssql是Patrik Simek的2.1.1版。
我可以连接到我们的数据库我准备了一个语句但是执行永远不会被调用。在执行代码之前,我知道建立了与数据库的连接。
//The client object contains the user name eg. "First Last"
var aryNames = objClient['usr'].split(" ");
if ( !(aryNames && aryNames.length) ) {
return;
}
var strSQL = "SELECT" +
" MIN(EventID)" +
",MAX(EventID)" +
",MIN(EventTime)" +
",MAX(EventTime)" +
",FirstName" +
",Surname" +
" FROM" +
" [Net2].[sdk].[EventsEx]" +
" WHERE" +
" CAST(EventTime AS Date) BETWEEN @bow AND @eow" +
" AND FirstName=@firstname" +
" AND Surname=@surname" +
" GROUP BY" +
" CONVERT(VARCHAR(10), EventTime, 102)" +
",FirstName" +
",Surname",
objParams = {bow : objClient['tk_bow']
,eow : objClient['tk_eow']
,firstname : aryNames[0]
,surname : aryNames[aryNames.length-1]},
ps = new mssql.PreparedStatement();
ps.input("bow", mssql.DateTime2);
ps.input("eow", mssql.DateTime2);
ps.input("firstname", mssql.VarChar);
ps.input("surname", mssql.VarChar);
ps.prepare(strSQL, function(err) {
console.log("prepare");
if ( err ) {
console.log(err);
return;
}
ps.execute(objParams, function(err, recordset) {
console.log("execute");
console.log(err);
console.dir(recordset);
ps.unprepare(function(err) {
});
});
});
执行此代码时,将显示调试语句prepare,但我从未看到execute语句。
我看了很多例子,我看不出我做错了什么。
答案 0 :(得分:0)
我修改了我的连接例程,修复了它。