Q&A

  • ADO ODBC에서 질의 수행시 에러입니다
다음의 프로시저가 수행되어 질의를 수행하고

procedure TForm1.btnSearchPackageClick(Sender: TObject);
var i, j : Integer;
begin
    with ADOQuery1 do
    begin
        if Active then Active := false;
        SQL.Clear;
        SQL.Add('select mdno, mdfileid, mdlang, mdchrcode, hrlevcode, hrlevname, mddate, mdname, mdver from mdtbl');
        SQL.Add(' where mdno in (select mdno from dstbl where dsno in(select dsno from cttbl where title like ''%'+ eTitle.Text + '%''))');
        SQL.Add(' order by mdno');

        Active := true;

        first;
        if Recordcount = 0 then
        begin
            MessageDlg('조회결과가 없습니다', mtConfirmation, mbOKCancel, 0);
            exit;
        end;
        sgMetaList.RowCount := RecordCount + 1;

        i := 0;
        while Eof = false do
        begin
            for j := 0 to 8 do
            begin
                    sgMetaList.Cells[j, i + 1] := Fields[j].AsString;
            end;
            Next;
            i := i+1;
        end;

     end;
  end;


다음 프로시저를 수행할때  Active := false부분에서 exception이 발생합니다
exception의 내용은
Either BOF or EOF is True, or the current record has been deleted. Requested operaion requires a current record
입니다
왜 이런 일이 발생하는지 모르겠습니다
고수님들의 조언 바랍니다
procedure TForm1.sgMetaListDblClick(Sender: TObject);
var i : Integer;
begin
    with ADOQuery1 do
    begin
          if Active then
        begin;
              Active := false;
          end;
        SQL.Clear;
        SQL.Add('select mdno, mdfileid, mdlang, mdchrcode, hrlevcode, hrlevname, mddate, mdname, mdver from mdtbl');
        SQL.Add(' where mdno=' + sgMetaList.Cells[0, sgMetaList.Row]);
        Active := true;
        first;
        if Recordcount = 0 then
        begin
            MessageDlg('조회결과가 없습니다', mtConfirmation, mbOKCancel, 0);
            exit;
        end;

...
    end;

end;
1  COMMENTS