各位,前辈们,大家好,请帮我看看下面这个sql 执行,怎么会没结果呢?我的数据库是access 的,'报价单日期'的数据类型是 短日期 型的.
    Combobox1 是一个选择搜索项目,edit1 是 要搜索的内容.    
       SQL.Add('Select * from total_list where');
       SQL.Add(Trim(ComboBox1.Text));
       SQL.Add('like'''+'%'+Edit1.Text+'%'+'''');
       SQL.Add('and');
       SQL.Add( '报价单日期>=#'+datetostr(datetimepicker1.Date)+'# and 报价单日期<=#'+datetostr(datetimepicker2.Date)+'#') ;

解决方案 »

  1.   

    你这个SQL好象都连在一起了吧?比如 where name='123' and pass='456' 你的语句好象没有空格
      

  2.   

    将sql内容显示出来看看你的sql是否有问题,ShowMessage(SQL.Text);
      

  3.   

    datetimepicker1.Date中得出的不是日期值,而是日期和时间值,只是时间值隐藏了,时间值就是你调用时间的时间,
    所以在进行时间比较查询时,应该这样写
        dt1:=Self.DateTimePicker1.Date;
        dt2:=Self.DateTimePicker2.Date;
        DecodeDate(dt1,year1,mon1,day1);
        DecodeDate(dt2,year2,mon2,day2);
        if dt1<dt2 then
        begin
          dt1:=EncodeDateTime(year1,mon1,day1,0,0,0,0);
          dt2:=EncodeDateTime(year2,mon2,day2,23,59,59,99);
        end
        else
        begin
          dt1:=EncodeDateTime(year2,mon2,day2,0,0,0,0);
          dt2:=EncodeDateTime(year1,mon1,day1,23,59,59,99);
        end;
      

  4.   

    SQL.Add( '报价单日期>=#'+datetostr(datetimepicker1.Date)+'# and 报价单日期 <=#'+datetostr(datetimepicker2.Date)+'#') ;
    改成SQL.Add( '报价单日期>=dt1 and 报价单日期 <=dt2) ;
      

  5.   

    datetostr(datetimepicker1.Date)
    改为
    FormatDateTime('yyyy-mm-dd',datetimepicker1.Date),试试