RAD Studio VCL Reference
|
Lists the datasets currently using this connection component.
property DataSets [Index: Integer]: TDataSet;
__property TDataSet DataSets[int Index];
Use DataSets to access the datasets that are currently using the connection component. 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, its value changes when datasets are opened and closed.
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!
|