FireDAC.Comp.DataSet.TFDDataSet.GetClonedDataSet

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function GetClonedDataSet(AWithSettings: Boolean): TDataSet; override;

C++

virtual Data::Db::TDataSet* __fastcall GetClonedDataSet(bool AWithSettings);

Properties

Type Visibility Source Unit Parent
function public
FireDAC.Comp.DataSet.pas
FireDAC.Comp.DataSet.hpp
FireDAC.Comp.DataSet TFDDataSet

Description

Creates a new instance of the TDataSet derived class and clones the structure and data of this dataset to the new instance.

FireDAC.Comp.DataSet.TFDDataSet.GetClonedDataSet inherits from Data.DB.TDataSet.GetClonedDataSet. All content below this line refers to Data.DB.TDataSet.GetClonedDataSet.


Creates a new instance of the TDataSet derived class and clones the structure and data of this dataset to the new instance.

Use this method to create a cloned instance of this dataset. The NestedDataSetClass property determines the class type of this cloned dataset.

To control the properties of the cloned dataset, use the boolean parameter WithSettings:

  • WithSettings=true: the cloned dataset inherits the basic settings of this dataset.
  • WithSettings=false: the cloned dataset will use the default settings.

Note
Only the following classes support the cloning procedure:

If the TDataSet derived class does not support cloning, this method returns nil.

Examples

To clarify, consider the following sample code snippets. This sample illustrates how to create a new cloned instance of the TDataSet derived class, and then add the Name field values of the cloned dataset to the Memo component.

Delphi:

var
  FDMemTable1: TFDMemTable;
  Memo1 : TMemo;
  ds: TDataSet;
//...
ds := FDMemTable1.GetClonedDataSet(True);
try
  Memo1.Lines.Clear;
  while not ds.Eof do
  begin
    Memo1.Lines.Add(ds['Name']);
    ds.Next;
  end;
finally
  ds.Free;
end;

C++Builder:

{
        TFDMemTable *FDMemTable1;
        TMemo *Memo1;
        TDataSet *ds;        
// ...
	ds = FDMemTable1->GetClonedDataSet(true);
	__try {
		Memo1->Lines->Clear();
		while (! ds->Eof) {
			Memo1->Lines->Add(ds->FieldValues["Name"]);
			ds->Next();
		}
	}
	__finally {
		delete ds;
	}
}

See Also