Q&A

  • 쿼리한걸 배열에 넣을려고 하는데 accessviolation....
구현한 코드는 다음과 같습니다.
실행하면 accessviolation.... 에러가 뜹니다.
어디가 잘못되었는지 지도 바랍니다.

procedure TForm1.Button1Click(Sender: TObject);
var
     wert: array of array of string;
     i: integer;

begin
     with Sqlwork do
     begin
          Close;
          Sql.Clear;
          Sql.Add('Select * from tablename');
          Open;
          First;
          if RecordCount > 0 then
          begin
              while not Eof do
               begin
                         wert[i, 0] := FieldByName('field1').AsString;  <===여기서 걸립니다.
                         wert[i, 1] := FieldByName('field2').AsString;
                         wert[i, 2] := FieldByName('field3').AsString;
                         Next;
                end;
          end;
     end;
end;


2  COMMENTS
  • Profile
    김흥식 2002.11.28 01:51
    array의 크기를 주시면 될듯하네요...
    이렇케..

    procedure TForm1.Button1Click(Sender: TObject);
    var
         wert: array of array of string;
         i: integer;

    begin
         with Sqlwork do
         begin
              Close;
              Sql.Clear;
              Sql.Add('Select * from tablename');
              Open;
              First;
              if RecordCount > 0 then
              begin
                  i := 0;                //<-- 요거랑
                  setlength(wert,RecordCount,3);  //<-- 요거랑
                  while not Eof do
                   begin
                             wert[i, 0] := FieldByName'field1').AsString;
                             wert[i, 1] := FieldByName('field2').AsString;
                             wert[i, 2] := FieldByName('field3').AsString;
                             inc(i);  //<-- 요거랑
                             Next;
                    end;
              end;
         end;
    end;



  • Profile
    하기현 2002.11.28 03:33
    지도에 감사드립니다.