TADOQuery 로 가져온 결과를 TStringGrid 에 뿌려주는 프로시저 입니다.
예전에 디비그리드 쓰기 시러서 걍 한번 만들어 봤었습니당..^^;;
{==============================================================
sQry 의 결과를 sGrid 에 출력
--------------------------------------------------------------}
procedure Put_StringGrid_QryData(sGrid : TStringGrid; sQry : TADOQuery);
var i,j : integer;
begin
for j:= 0 to TStringGrid(sGrid).RowCount - 1 do
for i:= 0 to TStringGrid(sGrid).ColCount - 1 do
TStringGrid(sGrid).Cells[i,j] := '';
for i:= 1 to TStringGrid(sGrid).ColCount - 1 do
TStringGrid(sGrid).Cells[i,0] := TADOQuery(sQry).Fields[i-1].FieldName;
TADOQuery(sQry).First;
for j:= 1 to TStringGrid(sGrid).RowCount - 2 do begin
TStringGrid(sGrid).Cells[0,j] := IntToStr(j);
for i:= 1 to TStringGrid(sGrid).ColCount - 1 do
TStringGrid(sGrid).Cells[i,j] := TADOQuery(sQry).Fields[i-1].AsString;
TADOQuery(sQry).Next;
end;
for i := 1 to TStringGrid(sGrid).ColCount - 1 do
TStringGrid(sGrid).Cells[i,TStringGrid(sGrid).RowCount - 1] := '';
end;
TADOQuery 로 가져온 결과를 TStringGrid 에 뿌려주는 프로시저 입니다.
예전에 디비그리드 쓰기 시러서 걍 한번 만들어 봤었습니당..^^;;
{==============================================================
sQry 의 결과를 sGrid 에 출력
--------------------------------------------------------------}
procedure Put_StringGrid_QryData(sGrid : TStringGrid; sQry : TADOQuery);
var i,j : integer;
begin
for j:= 0 to TStringGrid(sGrid).RowCount - 1 do
for i:= 0 to TStringGrid(sGrid).ColCount - 1 do
TStringGrid(sGrid).Cells[i,j] := '';
TStringGrid(sGrid).ColCount := TADOQuery(sQry).FieldCount + 1;
TStringGrid(sGrid).RowCount := TADOQuery(sQry).RecordCount + 2;
for i:= 1 to TStringGrid(sGrid).ColCount - 1 do
TStringGrid(sGrid).Cells[i,0] := TADOQuery(sQry).Fields[i-1].FieldName;
TADOQuery(sQry).First;
for j:= 1 to TStringGrid(sGrid).RowCount - 2 do begin
TStringGrid(sGrid).Cells[0,j] := IntToStr(j);
for i:= 1 to TStringGrid(sGrid).ColCount - 1 do
TStringGrid(sGrid).Cells[i,j] := TADOQuery(sQry).Fields[i-1].AsString;
TADOQuery(sQry).Next;
end;
for i := 1 to TStringGrid(sGrid).ColCount - 1 do
TStringGrid(sGrid).Cells[i,TStringGrid(sGrid).RowCount - 1] := '';
end;