RAD Studio VCL Reference
|
Indicates the number of datasets associated with the connection component.
property DataSetCount: Integer;
__property int DataSetCount;
Use DataSetCount to determine the number of datasets listed by the DataSets property. Depending on the TCustomConnection descendant, DataSets may include only the active datasets that use the connection component (as is the case with TDatabase and TSQLConnection), or it may list all datasets, regardless of whether they are active (as is the case with TADODatabase and DataSnap connection components TSOAPConnection). If DataSets includes only active datasets, the value of DataSetCount changes when datasets are opened and closed.
Use DataSetCount as an upper bound when iterating through the DataSets property.
Delphi Examples:
{ The following code fragment illustrates how DataSets and DataSetCount can be used to ensure that an action is taken for every open dataset. Assign CheckButtonActive as the AfterClose and AfterOpen event handlers for TClientDataSet1. } procedure TForm1.Button1Click(Sender: TObject); var I: Integer; begin if not RemoteServer1.Connected then RemoteServer1.Connected := True; ClientDataSet1.Close; with RemoteServer1 do begin for I := 0 to DataSetCount - 1 do DataSets[I].EnableControls; end; ClientDataSet1.Open; end; procedure TForm1.Button3Click(Sender: TObject); var I: Integer; begin ClientDataSet1.Close; RemoteServer1.Connected := False; with RemoteServer1 do begin for I := 0 to DataSetCount - 1 do DataSets[I].DisableControls; end; end; procedure TForm1.CheckButtonActive(DataSet: TDataSet); begin Button1.Enabled := not ClientDataSet1.Active; Button2.Enabled := ClientDataSet1.Active; Button3.Enabled := ClientDataSet1.Active; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|