unit Unit121;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, Data.DB, Datasnap.DBClient,
Vcl.StdCtrls,
FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param,
FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf,
FireDAC.Comp.DataSet, FireDAC.Comp.Client;
type
TForm121 =
class(TForm)
gb_clientdataset: TGroupBox;
b_clientdataset_add: TButton;
b_clientdataset_delete: TButton;
l_clientdataset: TLabel;
gb_fdmemtable: TGroupBox;
l_fdmemtable: TLabel;
b_fdmemtable_add: TButton;
b_fdmemtable_delete: TButton;
procedure b_clientdataset_addClick(Sender: TObject);
procedure b_clientdataset_deleteClick(Sender: TObject);
procedure b_fdmemtable_addClick(Sender: TObject);
procedure b_fdmemtable_deleteClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
lClientDataSet: TClientDataSet;
lFDMemTable: TFDMemTable;
procedure Add( xDataset: TDataSet;
xLabel: TLabel);
procedure Delete( xDataset: TDataSet;
xLabel: TLabel);
end;
var
Form121: TForm121;
implementation
{$R *.dfm}
procedure TForm121.Add(xDataset: TDataSet; xLabel: TLabel);
begin
for var i := 1
to 9999
do
begin
xDataset.Append;
xDataset.FieldByName('
TEST1').AsString := Random( MaxInt).ToString;
xDataset.FieldByName('
TEST2').AsString := Random( MaxInt).ToString;
xDataset.FieldByName('
TEST3').AsString := Random( MaxInt).ToString;
xDataset.Post;
end;
xLabel.Caption := Format( '
Recordcount: %d', [ xDataset.RecordCount]);
end;
procedure TForm121.b_clientdataset_addClick(Sender: TObject);
begin
Add( lClientDataSet,
l_clientdataset);
end;
procedure TForm121.b_clientdataset_deleteClick(Sender: TObject);
begin
Delete( lClientDataSet,
l_clientdataset);
end;
procedure TForm121.b_fdmemtable_addClick(Sender: TObject);
begin
Add( lFDMemTable,
l_fdmemtable);
end;
procedure TForm121.b_fdmemtable_deleteClick(Sender: TObject);
begin
Delete( lFDMemTable,
l_fdmemtable);
end;
procedure TForm121.Delete(xDataset: TDataSet; xLabel: TLabel);
begin
while ( xDataset.RecordCount > 0)
do
begin
xDataset.Delete;
end;
xLabel.Caption := Format( '
Recordcount: %d', [ xDataset.RecordCount]);
end;
procedure TForm121.FormCreate(Sender: TObject);
begin
Randomize;
lClientDataSet := TClientDataSet.Create( Self);
lClientDataSet.FieldDefs.Add( '
TEST1', ftString, 500);
lClientDataSet.FieldDefs.Add( '
TEST2', ftString, 500);
lClientDataSet.FieldDefs.Add( '
TEST3', ftString, 500);
lClientDataSet.CreateDataSet;
lFDMemTable := TFDMemTable.Create( Self);
lFDMemTable.FieldDefs.Add( '
TEST1', ftString, 500);
lFDMemTable.FieldDefs.Add( '
TEST2', ftString, 500);
lFDMemTable.FieldDefs.Add( '
TEST3', ftString, 500);
lFDMemTable.CreateDataSet;
end;
end.