像这样: 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;
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;
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;
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;