procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
begin
Query1.Open;
StringGrid1.RowCount:=Query1.RecordCount;
StringGrid1.ColCount:=Query1.FieldCount;
for i:=1 to StringGrid1.RowCount do
StringGrid1.Cells[0,i]:=IntToStr(i);
for i:=1 to StringGrid1.ColCount do
StringGrid1.Cells[i,0]:=Query1.Fields[i-1].FieldName;
for i:=1 to StringGrid1.RowCount do
begin
Query1.First;
while not Query1.Eof do
begin
for j:=1 to StringGrid1.RowCount do
begin
StringGrid1.Cells[j,i]:=Query1.Fields[j-1].AsString;
end;
Query1.Next;
end;
end;
end;