[Overview][Types][Classes][Procedures and functions][Index] | Reference for unit 'BufDataset' (#fcl)

# TCustomBufDataset.SaveToStream

Saves the dataset to the specified stream using the given data format

## Declaration

Source position: bufdataset.pas line 648

`public procedure TCustomBufDataset.SaveToStream(`
`AStream: TStream;`
`Format: TDataPacketFormat = dfBinary`
`);`

## Arguments

`AStream` |  | Stream used to save values
`Format` |  | Format used for values saved to the stream

## Description

SaveToStream is a procedure used to store the content in the buffered dataset to a stream using the specified data format.

AStream is a TStream decendant where the field definitions and record data in the dataset will be stored.

Format is a TDataPacketFormat enumeration value that indicates the format used to stored dataset values into the stream. The default value is dfBinary, and causes the TFpcBinaryDatapacketReader to be used to write the content for the dataset. Use another value from the TDataPacketFormat enumeration to select a different registered data packet handler that handles the associated data format.

SaveToStream calls the CheckBiDirectional method to ensure that the dataset is opened for bi-directional record navigation. An Exception is raised if the UniDirectional property contains True. A temporary TDataPacketReader instance is created using the specified Format. SaveToStream calls the GetDatasetPacket method using the data packet handler to store the content in the buffered dataset to the stream.

SaveToStream is used in the implementation of the SaveToFile method.

## See also

TCustomBufDataset.UniDirectional |  | Indicates if the dataset is for uni-directional navigation only
TCustomBufDataset.SaveToFile |  | Saves the dataset to the specified file using the given data format
TDataPacketFormat |  | Indicates the format used for data packets in TBufDataset
RegisterDatapacketReader |  | Registers a data packet reader using a specific format for TBufDataset
TDataPacketReaderClass |  | Class type used to create data packet readers for TBufDataset
TDataPacketReader |  | Implements a data packet reader for TBufDataset

Documentation generated on: May 14 2021