for i:=0 to adoquery4.FieldCount-1 do begin
stringgrid1.Cells[i,0]:=adoquery4.Fields[i].FieldName;
end;
first;
j:=1;
while not adoquery4.Eof do begin
stringgrid1.Cells[0,j]:=fields[0].AsString;
stringgrid1.Cells[1,j]:=fields[1].AsString;
stringgrid1.Cells[2,j]:=fields[2].AsString;
stringgrid1.Cells[3,j]:=fields[3].AsString;
stringgrid1.Cells[4,j]:=fields[4].AsString;
stringgrid1.Cells[5,j]:=1-fields[5].AsVariant;
for i:=6 to adoquery4.FieldCount-1 do begin
stringgrid1.Cells[i,j]:=fields[i].AsString;
end;
next;
inc(j);
end;
end;