The following code fragment illustrates how DataSets and DataSetCount can be used to ensure
that an action is taken for every open dataset that is a table.
After that all open datasets will be closed.
var
I: Integer;
begin
with MySQLDatabase1 do
begin
while DataSetCount <> 0 do
begin
if DataSets[0] is TMySQLTable then
begin
// Some code
end;
DataSets[0].Active := False;
end;
end;
end;