구현한 코드는 다음과 같습니다.
실행하면 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;
이렇케..
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;