我在做一个仓库管理系统,我想要查询库中某一时间段的库存量,查询语句如下:
if trim(flatcombobox1.Text)<>''   and  trim(flatcombobox2.Text)<>'' then begin
query1.close;
query1.sql.clear;
query1.sql.add('select *from kucun where 进货时间  between '''+flatcombobox1.text+''' and '''+flatcombobox2.text+'''');
query1.open;
end;
但是我在运行的时候却不成功,请慰问是什么原因啊

解决方案 »

  1.   

    operator not applicable to this operand
      

  2.   

    operator not applicable to this operand type
      

  3.   

    if trim(flatcombobox1.Text)<>''   and  trim(flatcombobox2.Text)<>'' then begin
    //then和begin不该同行,要换行
    query1.close;
    query1.sql.clear;
    query1.sql.add('select *from kucun where 进货时间  between '''+flatcombobox1.text+''' 
                   //你看提示错误时是不是在这行,你把*from中加个空格看看,还有进货时间和between多了个空格
    and '''+flatcombobox2.text+'''');
    query1.open;
    end;
    我用的是BDE啊//bde只是连接方式,不是数据库,它可以连接sqlserver,access等数据库,我猜你用的是delphi自带的paradox吧。
      

  4.   

    高手还是不行啊我是用的DELPHI自带的paradox啊
    是在查询方式中一共有四种可查询:分别为按进货时间,型号,串号,供货方查询等组合查询,代码如下:
    procedure TForm6.FlatButton1Click(Sender: TObject);
    begin
    with query1 do
    begin
    Close;
    SQL.Clear;
    SQL.Add('select * from kucun');
    sql.Add('where 1=1');
    if trim(flatcombobox1.Text)<>''   and  trim(flatcombobox4.Text)<>'' then//这行有错
       begin
       sql.add('and 进货时间 between '''+flatcombobox1.text+''' and '''+flatcombobox2.text+'''');
       end;
    if trim(flatmaskedit1.Text)<>'' then
       SQL.Add('and 供货方='''+flatmaskedit1.Text+'''');
    if trim(flatmaskedit2.Text)<>'' then
       SQL.Add('and 型号='''+flatmaskedit2.Text+'''');
    if trim(flatmaskedit3.Text)<>'' then
       SQL.Add('and 串号='''+flatmaskedit3.Text+'''');
    Open;
    错误显示operator not applicable to this operand type和could not compile used unit 'jinhuosearchunit.pas'啊不知道是什么原因啊
      

  5.   

    procedure TForm6.FlatButton1Click(Sender: TObject);
    begin
    with query1 do
    begin
    Close;
    SQL.Clear;
    SQL.Add('select * from kucun');
    sql.Add(' where 1=1');
    if trim(flatcombobox1.Text)<>''   and  trim(flatcombobox4.Text)<>'' then//这行有错
       begin
       sql.add(' and 进货时间 between '''+flatcombobox1.text+'''   and '''+flatcombobox2.text+'''');
       end;
    if trim(flatmaskedit1.Text)<>'' then
       SQL.Add(' and 供货方='''+flatmaskedit1.Text+'''');
    if trim(flatmaskedit2.Text)<>'' then
       SQL.Add(' and 型号='''+flatmaskedit2.Text+'''');
    if trim(flatmaskedit3.Text)<>'' then
       SQL.Add(' and 串号='''+flatmaskedit3.Text+'''');
    Open;
      

  6.   

    //这是我以前的代码,能运行的
     //isExist为一字符串.. 
      isExist := 'Select * from worker where 1>0';
      if(trim(Self.Edit60.Text) <>'') then
          isExist := isExist + ' and id=:id';
      if(trim(Self.Edit61.Text) <>'') then
          isExist := isExist + ' and Name=:Name';
      if(trim(Self.Edit62.Text) <>'') then
          isExist := isExist + ' and gw=:gw';
      if(Self.Edit60.Text<>'') or (Self.Edit61.Text<>'') or (Self.Edit62.Text<>'') then
        begin
          with DataModule1.ADOQuery1 do
            begin
              SQL.Clear;
              SQL.Add(isExist);
              if(Self.Edit60.Text<>'') then
                Parameters.ParamByName('id').Value := trim(Self.Edit60.Text);
              if(Self.Edit61.Text<>'') then
                Parameters.ParamByName('Name').Value := trim(Self.Edit61.Text);
              if(Self.Edit62.Text<>'') then
                Parameters.ParamByName('gw').Value := trim(Self.Edit62.Text);
              Open;
              if(RecordCount=0) then
                begin
                  Self.DBGridEh13.DataSource := nil;
                  showmessage('Error!');
                  Exit;
                end;
            end;
        end;