Delphi中如何用日期和其他条件,查询SQL的日期段内数据?

来源:百度知道 编辑:UC知道 时间:2024/06/08 18:27:18
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from zyqd where 职员姓名=:zyxm and 签到日期 between cong and dao');
adoquery1.Parameters.ParamByName('cong').Value:=datetostr(DateTimePicker1.Date);
adoquery1.Parameters.ParamByName('dao').Value:=datetostr(DateTimePicker2.Date);
adoquery1.Parameters.ParamByName('zyxm').Value:=combobox1.Text;
adoquery1.open;

运行时,老是在查询时,弹出('ADOQuuery1:Parmerter 'cong' not found'.)
本人菜鸟,请叫高手能解决下!谢谢!
单独运行
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from zyqd where 签到日期 between cong and dao');
adoquery1.Parameters.ParamByName('cong').Value:=datetostr(DateTimePicker1.Date);
adoquery1.Parameters.ParamByName('dao').Value:=datetostr(DateTimePicker2.Date);
adoquery1.open;
可以查询到相应的信息,但就是加了“职员姓名=:zyxm and ”,就不行了!

adoquery1.SQL.Add('select * from zyqd where 职员姓名=:zyxm and 签到日期 between cong and dao');
这句话改成:
adoquery1.SQL.Add('select * from zyqd where 职员姓名=:zyxm and 签到日期 between :cong and :dao');
也就是多加了两个冒号,冒号表示他们是参数。

职员姓名:=zyxm吧。赋值运算符。。