Loads field definitions and optional data from the specified TDataset.
Source position: memds.pp line 157
public procedure TMemDataset.CopyFromDataset( |
DataSet: TDataSet |
); |
DataSet: TDataSet; |
CopyData: Boolean |
); |
DataSet |
|
TDataset with the structure and optional data loaded in the method. |
DataSet |
|
TDataset with the structure and optional data loaded in the method. |
CopyData |
|
True when record data is loaded from the source dataset. |
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.
|
Indexed access to the fields of the dataset. |
|
|
Definitions of available fields in the underlying database. |
|
|
Creates the internal storage for records in the in-memory dataset. |
|
|
Append a new record to the data. |
|
|
Post pending edits to the database. |