注册 登录
编程论坛 Delphi论坛

Datetimepicker 控件的问题!!

xytkf 发布于 2006-09-30 14:05, 979 次点击

这里是一个SQL的查询问题
我要在SQL语句中加一个条件:使要查这个表的datebook这个日期型的字段在
Datetimepicker1与Datetimepicker2之间


procedure TfrmLogin.speOKClick(Sender: TObject);
begin

with ADOLogin do
begin
Close;
SQL.Clear;
SQL.Add('select * from tbUser where datebook between datebook =:d1 and datebook =:d2');
Parameters.ParamByName(d1).Value :=strtodatetime(Datetimepicker1.Date);
parameters.ParamByName('d2').Value :=strtodatetime(Datetimepicker2.Date);
Open;
end;
end.

这样子的语句运行时一直会出错这是为什么呢?
请高手们帮我指教下!
急用谢谢了!!

3 回复
#2
volte2006-09-30 20:10
DateTimePicker.Date 已经是TDateTime类型了

你为什么还要进行strtodatetime 转换

这样肯定会报错误的!
#3
jiu232006-10-09 15:41
同意楼上的说法
直接将付值语句写为:Parameters.ParamByName(d1).Value := DateTimePicker1.Date;试一下
#4
zjbfvfv2006-10-09 22:17
SQL.Add('select * from tbUser where datebook between datebook =:d1 and datebook =:d2');
为什么会 =: d1 与 =: d2?
还有如果你数据类型是日期类型就无须进行转换了另按你的说查询在此日期段之间那么你的SQL语名就更有问题了

找到一个不错的论坛: http://www.21ki.cn/index.php?cateid=325 有很多Delphi的资料
1