请教一个ACCESS数据库中关于日期的SQL问题.(100分)

J

jbas

Unregistered / Unconfirmed
GUEST, unregistred user!
下面的sql为什么总是不行,提示参数错误。ADO+access+D6+win2000
close;
sql.clear;
sql.Add('select DoMan,DoTime,DoCnt from 日志表 where DoTime between :Ds and :De');
parameters.ParamByName('Ds').Value:=ACs.ADstart;
parameters.ParamByName('De').Value:=ACs.ADend;
end;
try
execsql;


 
'select DoMan,DoTime,DoCnt from 日志表 where DoTime between #:Ds# and #:De#'
 
你不妨把形成的SQL语句拷贝到Access中执行,看是否成功。
 
把参数赋值中的 value 去掉呢?
看看 Access 和 Delphi 中的日期表达是否一致。
 

sql.Add('select DoMan,DoTime,DoCnt from 日志表 where DoTime between :Ds and :De');
=====> parameters.ParamByName('Ds').datetype:=ftDateTime;
parameters.ParamByName('Ds').Value:=ACs.ADstart;
=====> parameters.ParamByName('De').datetype:=ftDateTime;
parameters.ParamByName('De').Value:=ACs.ADend;
 
谢谢各位了,我把datatime改string了,这样省心。
 
顶部