2005. augusztus 5., péntek

How to open or close all datasets in on the form


Problem/Question/Abstract:

How to open or close all datasets in on the form

Answer:

Open datasets: OpenDataSet(MyForm);

procedure OpenDataSet(FormName: TForm);
var
  I: Integer;
begin
  for I := FormName.ComponentCount - 1 downto 0 do
    if (FormName.Components[I] is TADOTable) then
    begin
      (FormName.Components[I] as TADOTable).Open;
    end;
end;

Close datasets: CloseDataSet(MyForm);

procedure CloseDataSet(FormName: TForm);
var
  I: Integer;
begin
  for I := FormName.ComponentCount - 1 downto 0 do
    if (FormName.Components[I] is TADOTable) then
    begin
      (FormName.Components[I] as TADOTable).Close;
    end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése