我想通过设置ADOTable的过滤条件组合来进行查询,可老出错!
代码如下:
if CK_date.Checked then
   FilterStr:='bill_date='''+i_start_date.Text+'''';
if CK_car.Checked then
    begin
     if length(FilterStr)>0 then
        FilterStr:=FilterStr+' and ';
     FilterStr:=FilterStr+'car_id='''+i_search_car.Text+'''';
    end;

解决方案 »

  1.   

    if CK_date.Checked then
       FilterStr:='bill_date='''+i_start_date.Text+'''';
        类型是否正确? bill_date的类型是否是string?????
      

  2.   

    问题是当只有一种查询条件的时候,即只有CK_car.Checked=false的时候执行是正确!
      

  3.   

    if CK_date.Checked then begin
      FilterStr:='bill_date='''+i_start_date.Text+''' and '
                +'car_id='''+i_search_car.Text+''' ';
    end;
    为什么不这样写你的代码?
    出错是不是因为:bill_date='''+i_start_date.Text+'''的类型有问题?
    该字段是日期型的吧!^_^
      

  4.   

    有的时候不用'car_id='''+i_search_car.Text+''' '这个查询条件,