Unit 'BufDataset' Package
[Overview][Types][Classes][Procedures and functions][Index] [#fcl]

TCustomBufDataset.CopyFromDataset

Loads field definitions and optional data from another dataset.

Declaration

Source position: bufdataset.pas line 681

public procedure TCustomBufDataset.CopyFromDataset(

  DataSet: TDataSet;

  CopyData: Boolean = True

);

Arguments

DataSet

  

Dataset with values copied in the method.

CopyData

  

True when record data is included in the copy operation.

Description

CopyFromDataset is a procedure used to copy field definitions and optional record data for the dataset specified in the Dataset argument. CopyData indicates if record data is included in the copy operation. When CopyData contains False, only the field definitions in DataSet are copied to the buffered dataset.

CopyFromDataset calls the Close method prior to performing actions that clear field definitions and bound fields in the buffered dataset. A field definition is added to FieldDefs for each of the fields in DataSet. CreateDataset is called to bind Fields to the new field definitions, and to initialize index storage for the buffered dataset.

When CopyData contains True, record data from DataSet is copied to the class instance on a row-by-row and field-by-field basis. Append is called to add a new record. Internal lists with field definitions and bound fields are used to copy field values in the record (including Blob fields). Null field values are not copied in the method. The DataType for the field is used to read/write the field values. For blob fields, a temporary stream is used to read/write the field value. The Post method is called to store appended values in the buffered dataset. If an exception is raised, the Cancel method is called to clear the update and the exception is re-raised.

The record position in DataSet is restored to its original position prior to exiting from the method.

See also

TDataset.Close

  

Close the dataset.

TDataset.Cancel

  

Cancel the current editing operation.

TDataset.FieldDefs

  

Definitions of available fields in the underlying database.


Documentation generated on: Dec 27 2024