with query1 do begin
     sql.clear;
     sql.add('select * from myTable where Birth=:fBirth');
     params[0].AsDatetime := DateTimePicker.DateTime;
     Open;
end;

解决方案 »

  1.   

    ADODataSet中用parameters.parambyname('fbirth').value:=DateTimePicker.Date也可以直接在SQL语句中直接赋值:
    Sql.text:='select * from myTable where Birth=#'+
               datetostr(DateTimePicker.Date)+'#'
      

  2.   

    我这样写的
    fADODataSet.CommandText:='select * from V_Authors Where Birth=#'+DatetoStr(fBirth.Date)+'#';
    但是还是不行啊。上面的直接写的方法也不行
      

  3.   

    'select * from V_Authors Where Birth='+DateToStr(fBirth.Date)
      

  4.   

    你的方法给了我启示,改成下面的就可以了
    'select * from V_Authors Where Birth='+''''+DateToStr(fBirth.Date)+''''成功,
    但是有时间参数一定要这样写吗? 
      

  5.   

    ADODataSet1.CommandText := 
      Format('select * from tablename where birth=''%s''', [DataPicker.Date)];
    用Format比较方便