delphi中在怎么从数据库选出edit1内容与edit2的内容进行比较,若edit1<edit2执行,否则不执行

解决方案 »

  1.   

    我想在edit1里输上查询的编号,在edit2里输入要求的数量,用button,然后根据编号与数据库里的数量进行比较,若要求的数量小于库存量显示可以执行添加,否则不能
      

  2.   

    像这样:
    with adoquery1 do
    begin
     close;
     sql.text:='select * from t where 编号='+Quotedstr(Edit1.Text)+' and 库存量<'+Edit2.Text;
     open;
     if isEmpty then
     begin
       {添加代码}
       showmessage('添加成功');
     end else
     showmessage('要求的数量大于库存量,不可添加');
    end;
      

  3.   

    我想在edit1里输上查询的编号,在edit2里输入要求的数量,用button,然后根据编号与数据库里的数量进行比较,若要求的数量小于库存量显示可以卖出,否则不能
      

  4.   

    Trim(edit1.text),得到字符型数据,然后作为参数传到你的数据中
      

  5.   


    procedure TForm1.Button1Click(Sender: TObject);
    begin
      with ADOQuery1 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select * from table1 where 编号='''+edit1.Text+''' and 库存数 >= '+edit2.Text+' ');
        Open;
        if recordcount>0 then
        begin
          ShowMessage('可以执行');
        end else
          ShowMessage('不能执行');
      end;
    end;