procedure TForm1.Button1Click(Sender: TObject);
var sql:string;
begin
sql:='select * from  ss_qbjl  where  fm_bh='''+intTostr(MaskEdit1)+'''';
sql:=sql+ 'qbdate between  ''''+DateTimePicker1+''''+ and +''''+DateTimePicker2+''''' ;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(sql);
Query1.Prepare;
Query1.Active:=true;这里是fm-bh是字符型

解决方案 »

  1.   

    sql:='select * from  ss_qbjl  where  fm_bh='''+intTostr(MaskEdit1)+''' and ';
    sql:=sql+ 'qbdate between  ''''+DateToStr(DateTimePicker1.Date)+''''+ and +''''+DateToStr(DateTimePicker2.Date)+''''' ;
      

  2.   

    sql:='select * from  ss_qbjl  where  fm_bh='''+intTostr(MaskEdit1)+''' and ';
    sql:=sql+ 'qbdate between  ''''+DateToStr(DateTimePicker1.Date)+''''+ and +''''+DateToStr(DateTimePicker2.Date)+''''' ;
      

  3.   

    sql:='select * from  ss_qbjl  where  fm_bh='''+intTostr(MaskEdit1)+'''';
    sql:=sql+ 'qbdate between  ''''+DateTimePicker1+''''+ and +''''+DateTimePicker2+''''' ; 
    //如果qbdate是日期型的字段DateTimePicker要转化成字符再转化成日期的
    Query1.Close;
    Query1.SQL.Clear;
    Query1.SQL.Add(sql);Query1.Prepare;Query1.Active:=true;
    //改成query1.open;
      

  4.   

    //如果qbdate是日期型的字段DateTimePicker要转化成字符再转化成日期的
    先将DateTimePicker转化成字符型的用delphi的函数.
    再转化成日期的用数据库的函数.
      

  5.   

    1 and (line1后面)
    2 空格(line1后面)
    3 DateToStr(DateTimePicker.Date)
      

  6.   

    4 sql:=sql+ 'qbdate between  ''''+DateToStr(DateTimePicker1.Date)+''' and '''+DateToStr(DateTimePicker2.Date)+'''' ;//and错而且最后多了一个引号
      

  7.   

    to firetoucher(风焱)  
    报错
    [Error] Unit1.pas(36): There is no overloaded version of 'IntToStr' that can be called with these arguments
    [Fatal Error] Project1.dpr(5): Could not compile used unit '..\..\..\D-Tools\Unit1.pas'to hammer_shi(@农业专家@(*暂时是菜鸟*)) 
    [Error] Unit1.pas(36): There is no overloaded version of 'IntToStr' that can be called with these arguments
    [Fatal Error] Project1.dpr(5): Could not compile used unit '..\..\..\D-Tools\Unit1.pas'
     
      

  8.   

    检查你哪里使用了IntToStr函数.
      

  9.   

    小弟,多看看delphi帮助吧/
    上面的:
    intTostr(MaskEdit1)改成:MaskEdit1.text
      

  10.   

    sql:='select * from  ss_qbjl  where  fm_bh='+''''+intTostr(MaskEdit1.text)+'''';
    sql:=sql+ ' and qbdate between  '+DateToStr(DateTimePicker1.Date)+' and '  +DateToStr(DateTimePicker2.Date) ;
      

  11.   

    不好意思,更正:sql:='select * from  ss_qbjl  where  fm_bh='+''''+MaskEdit1.text+'''';
    sql:=sql+ ' and qbdate between  '+DateToStr(DateTimePicker1.Date)+' and '  +DateToStr(DateTimePicker2.Date) ;