delphi查询数据库内容是空的
qryNumber.SQL.Add('select IntraLabelNo,TeamNumber from OrderRec ');
qryNumber.SQL.Add('where printed=1 and PrintDT between :P0 and dateadd(second,1,:P0)');
qryNumber.Parameters.ParamByName('P0').Value:=FormatDateTime('yyyy-mm-dd hh:nn:ss',time);
MS SQL数据库,用这个查询是空的结果,为什么??这样写有什么不妥吗?
[解决办法]
你打印以下你的sql语句就看出问题了.
time函数出的是时间, 不包含日期.是不是用错了?!
做如下替换试试
//qryNumber.Parameters.ParamByName('P0').Value:=FormatDateTime('yyyy-mm-dd hh:nn:ss',time);
qryNumber.Parameters.ParamByName('P0').Value:=FormatDateTime('yyyy-mm-dd hh:nn:ss',now);