CommandText (Delphi)
Contents
Description
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.
Code
procedure TForm1.Button2Click(Sender: TObject);
begin
ClientDataSet1.PacketRecords := StrToInt(Edit1.Text);
ClientDataSet1.GetNextPacket;
end;
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;
// Memo1 must contain a "select * from xxx" employee, customer, client.
// Look in Program Files/Common Files/CodeGear Shared/Data for db files.
// Notice that using the CommandText does not necessarily imply that you should use a BeforeGetRecords event.
// Handler for the ClientDataSet or the DataSetProvider
ClientDataSet1.CommandText := Memo1.Lines.Text;
ClientDataSet1.Open;
end;