我在窗体中加入一个edit的控件,目的是在里面输入数字,然后通过查询比较得出结果库存小于等于这个数字的配件显示出来:下面的语句总是有误:procedure Ttongji3.BitBtn1Click(Sender: TObject);
begin
  if edit1.Text ='' then
     begin
     showmessage('请输入基数!');
     exit;
     end;
      adoquery1.close;
      adoquery1.sql.clear;
      adoquery1.sql.add('select * from kucun where kcsl<='+quotedstr(edit1.text)+' order by kcsl' );
      adoquery1.open;
     datasource1.DataSet :=adoquery1;
     dbgrid1.DataSource:=datasource1;
end;其中kcsl是库存表中的一个字段,是数值型的,不知道如何老处理这个查询,请帮忙,谢谢,分不多了不好意思!

解决方案 »

  1.   

    adoquery1.sql.add('select * from kucun where kcsl<='+StrToInt(edit1.text)+' order by kcsl' );
      

  2.   

    出现错误:
    [Error] chaxun3.pas(57): Incompatible types: 'String' and 'Integer'
    [Fatal Error] erjiku.dpr(19): Could not compile used unit 'chaxun3.pas'
      

  3.   

    adoquery1.sql.add('select * from kucun where kcsl<=:xx order by kcsl' );
    AdoQuery1.parameters[0].value:=StrToInt(Edit1.Text);
    AdoQuery1.Open
      

  4.   

    晕,呵呵.写错了
    adoquery1.sql.add('select * from kucun where kcsl<='+edit1.text+' order by kcsl' );
      

  5.   

    procedure Ttongji3.BitBtn1Click(Sender: TObject);
    begin
      if edit1.Text ='' then
         begin
         showmessage('请输入基数!');
         exit;
         end;
          adoquery1.close;
          adoquery1.sql.clear;
          adoquery1.sql.add('select * from kucun where kcsl<='''+quotedstr(edit1.text)+''' order by kcsl' );
          adoquery1.open;
         datasource1.DataSet :=adoquery1;
         dbgrid1.DataSource:=datasource1;
    end;试试看
      

  6.   

    edit1.text是string型的。要转成数值型的。strtoint()或strtofloat()
      

  7.   

    实践证明了一下是对了:        
    ADOQuery1.Close;
            AdoQuery1.Parameters.ParamByName('kcsl').value:=StrToInt(Edit1.Text);
            adoquery1.Open;
            datasource1.DataSet:=adoquery1;
            dbgrid1.DataSource :=DataSource1;
    sql语句在adoquery直接运行了
    谢谢各位!!