DataModuleDestroy overboard?
Posted: 13.08.2009, 21:32
I'm maintaining an existing project, and I've run across this code, but I can't imagine why it might be necessary. Since the query components on the data module form are owned by the data module, wouldn't their destroy mechanisms automatically be called when the program ends, and thus in turn each active query would be closed? It is my thinking that this code is not necessary. Do you agree?
Thank you.
Regards,
Rich
Code: Select all
procedure TDMGeneral.DataModuleDestroy(Sender: TObject);
var
i : integer;
s : String;
begin
Try
for i:=0 to ComponentCount-1 do
begin
if (Components[i] is tZQuery) then
begin
try
s:= Components[i].Name;
(Components[i] as tZQuery).Close;
finally
s:= Components[i].Name;
end;
end
else if (Components[i] is tZReadOnlyQuery) then
begin
try
s:= Components[i].Name;
(Components[i] as tZReadOnlyQuery).Close;
finally
s:= Components[i].Name;
end;
end;
end;
Except
Raise;
End;
end;
Regards,
Rich