i created a type
type
TStringArray = array of array of string;
function TDataModule4.GetList(TableName: String): TStringArray;
var
i : Integer;
begin
i:= 0;
with TFDQuery.Create(Nil) do
begin
Connection := ADConnectionMySQL;
SQL.Add(Format('Select * from %s', [TableName]));
Open;
First;
while not Eof do
begin
end;
Free;
end;
end;
I know get data using FieldByName, but i want to return all data in multidimensional array. How can i do this?
Here is how i want to return :
array[0]["column1"] = "value1"
array[0]["column2"] = "value2"
array[1]["column1"] = "value3"
array[1]["column2"] = "value4"
array[2]["column1"] = "value5"
array[2]["column2"] = "value6"
TStringArraywhich again is declared as a dynamic 2D array. UseSetLength()to give the array length and width and fill in the values in your while loop. Look in help for dynamic arrays andSetLength. The result of a function has an implicit name ofResultif that is the problem.array of string, it's a record of typed data. Your data model should also probably consider it in that way.