RAD Studio
|
All database connection components maintain a list of all datasets that use them to connect to a database. A connection component uses this list, for example, to close all of the datasets when it closes the database connection.
You can use this list as well, to perform actions on all the datasets that use a specific connection component to connect to a particular database.
The connection component automatically closes all datasets when you close its connection. There may be times, however, when you want to close all datasets without disconnecting from the database server.
To close all open datasets without disconnecting from a server, you can use the CloseDataSets method.
For TADOConnection and TIBDatabase, calling CloseDataSets always leaves the connection open. For TDatabase and TSQLConnection, you must also set the KeepConnection property to True.
To perform any actions (other than closing them all) on all the datasets that use a connection component, use the DataSets and DataSetCount properties. DataSets is an indexed array of all datasets that are linked to the connection component. For all connection components except TADOConnection, this list includes only the active datasets. TADOConnection lists the inactive datasets as well. DataSetCount is the number of datasets in this array.
var I: Integer; begin with MyDBConnection do begin for I := 0 to DataSetCount - 1 do DataSets[I].DisableControls; end; end;
for (int i = 0; i < MyDBConnection->DataSetCount; i++) MyDBConnection->DataSets[i]->DisableControls();
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|