Unit 'memds' Package
[Overview][Constants][Classes][Index] [#fcl]

TMemDataset.CopyFromDataset

Loads field definitions and optional data from the specified TDataset.

Declaration

Source position: memds.pp line 157

public procedure TMemDataset.CopyFromDataset(

  DataSet: TDataSet

);

procedure TMemDataset.CopyFromDataset(

  DataSet: TDataSet;

  CopyData: Boolean

);

Arguments

DataSet

  

TDataset with the structure and optional data loaded in the method.

Arguments

DataSet

  

TDataset with the structure and optional data loaded in the method.

CopyData

  

True when record data is loaded from the source dataset.

Description

CopyFromDataset is used to load field definitions and optional record data from the specified TDataset descendent. Dataset contains the TDataset used as the source for the structure and optional record data loaded in the method. CopyData indicates if record data is loaded in the method. When CopyData contains False, only the structure from Dataset is loaded in method.

CopyFromDataset removes any existing field definitions in FieldDefs, and any record data stored in the in-memory dataset. CopyFromDataset uses the Fields in the DataSet argument to determine the new structure for the in-memory dataset. This is done because the visible Fields in the dataset may differ from the actual field definitions. CopyFromDataset creates and adds a TFieldDef instance to FieldsDefs for each of the Fields in DataSet.

CopyFromDataset calls CreateTable to allocated record storage for the new field definitions in FieldDefs.

When CopyData contains True, record data from the DataSet argument is added to the in-memory dataset. When CopyData contains False, record data in the DataSet argument is ignored.

The Open method is called to activate both datasets. DisableControls is called for both TDatasets to prevent updates during record navigation. All records in DataSet are loaded into the in-memory dataset by calling Append and setting the value for each of the field definitions in the target. Field definitions with the following data types are loaded using the native type for the field:

All other field values are loaded using their AsString representation.

CopyFromDataset calls Post after adding each record in the dataset. If an exception occurs, the Cancel method is called and the exception is re-raised.

CopyFromDataset calls the EnableControls method in both datasets when record data has been loaded in the method. Please note that the record position in the DataSet argument is restored after loading record data.

See also

TDataset.Fields

  

Indexed access to the fields of the dataset.

TDataset.FieldDefs

  

Definitions of available fields in the underlying database.

TMemDataset.CreateTable

  

Creates the internal storage for records in the in-memory dataset.

TDataset.Append

  

Append a new record to the data.

TDataset.Post

  

Post pending edits to the database.


Documentation generated on: Nov 22 2024