为什么在调用 Locate 方法时会出现 Stack Overflow 异常?

Why do I get the Stack Overflow exception when calling Locate method?

我在使用 Locate 方法进行重复 TADOTable 查找时遇到问题。以下代码第一次执行时没有问题,但随后的任何执行都会抛出 Stack Overflow 异常。

procedure TForm14.Button1Click(Sender: TObject);
begin
  ADOTable1.Open;
  if not ADOTable1.Locate('Num-permis', Edit1.Text, []) then
    ShowMessage(' Try it with another number, the figure does not exist');
end;

我该如何解决这个问题?

您需要停止每次打开 table,或者每次都开始关闭它。第一个是我的偏好:

procedure TForm14.Button1Click(Sender: TObject); 
begin 
  if not ADOTable.Active then
    ADOTable1.Open; 
  if not ADOTable1.Locate('Num-permis', edit1.Text, []) then 
   ShowMessage(' Try it with another number, the figure does not exist'); 
end;