Iterating Through a Database Component’s Datasets

From InterBase

Go Up to Controlling Connections


A database component provides two properties that enable an application to iterate through all the datasets associated with the component: DataSets and DataSetCount.

DataSets is an indexed array of all active datasets (TIBDataSet, TIBSQL, TIBTable, TIBQuery, and TIBStoredProc) for a database component. An active dataset is one that is currently open. DataSetCount is a read-only integer value specifying the number of currently active datasets.

You can use DataSets with DataSetCount to cycle through all currently active datasets in code. For example, the following code cycles through all active datasets to set the CachedUpdates property for each dataset of type TIBTable to True:

var
  I: Integer;
begin
  for I := 0 to DataSetCount - 1 do
    if DataSets[I] is TIBTable then
      DataSets[I].CachedUpdates := True;
end;

Advance To: