关于DateTimePicker与查询的问题
我想通过DateTimePicker与button做一个根据时间查询数据库的功能,但不知为啥一直报错说参数入库时间没有默认值,数据库为access,里面的数据样式均为2011/1/1这样的,无论我把数据类型改成文本或日期/时间,都报错说没有默认值。求高手讲解下错误原因...
以下为查询代码:
procedure TDYCX.SpeedButton1Click(Sender: TObject);
begin
if RadioGroup1.Items[RadioGroup1.ItemIndex] = '入库' then
with ADoqueryCX do
begin
Close;
SQL.Text:='select * from 入库表 where 出库时间='''+datetostr(Datetimepicker1.Date)+'''';
Open;
end;
end;
[解决办法]
access数据库查询日期条件2边要加上#号
- Delphi(Pascal) code
SQL.Text:='select * from 入库表 where 出库时间=#'+datetostr(Datetimepicker1.Date)+'#';