有以下一个过程:
procedure Tform1.Selbook(tmpstr:string);
begin
  try
    with adoquery1 do begin
      close;
      sql.Clear;
      sql.Add (tmpstr);
      open;
      if adoquery1.RecordCount>0 then begin
        first;
        while not EOF do begin
          listbox1.Items.Add(adoquery1.fields[1].asstring);
          next;
        end;
        last;经试验,如不用这句,铁定出现错误提示没商量。
      end;
    end;
  except
    if adoquery1.Active then adoquery1.Close;
  end;
end;
当第一次调用该过程进行查询,查出的结果是空集时,第二次再调用该过程,出现如下提示:
Either BOF or EOF is true,or the current record has been deleted, Requested operation requires a cureent record.
结果就process stoped.
已经安装了MDAC2.7,问题依旧。
问题到底出在哪里?

解决方案 »

  1.   

    我也碰到过这样的问题,数据集移动到最后,必需到LAST或其它,才能关闭,否则就会出现的你的错误。
    我当时也是这么解决的,用TADODATASET,没有这样的错误。
    估计是TADOQUERY从TADODATASET继承的时候有些问题。具体是什么我也没有找到。
    我现在一直用TADODATASET
      

  2.   

    No.1:将RecordCount > 0 -> RecordCount <> 0//当RecordCount = -1 时,数据集里是有数据的。
    No.2:不要出现键值重复值。
      

  3.   

    procedure Tform1.Selbook(tmpstr:string);
    begin
      try
        with adoquery1 do begin
          close;
          sql.Clear;
          sql.Add (tmpstr);
          open;
          if adoquery1.RecordCount>0 then begin        
            while not EOF do begin
              listbox1.Items.Add(adoquery1.fields[1].asstring);
              next;
            end;
          end;
        end;
      except
        if adoquery1.Active then adoquery1.Close;
      end;
    end;
    去掉 first 和last 
      

  4.   

    我试试。但去掉了last好象是铁定要出错的
      

  5.   

    升级ADO,到微软中国下一MDAC2.7试一下。
      

  6.   

    已经升级MDAC到2.7版了。但问题仍旧
      

  7.   

    你的ado版本还是有问题,重新找一个
      

  8.   

    MDAC2.7是在微软中国下载的。
    双击得到的压缩文件,自动完成了安装,应该不会有问题吧?……