FireDAC.Comp.DataSet.TFDDataSet.LoadFromStream
Delphi
procedure LoadFromStream(AStream: TStream; AFormat: TFDStorageFormat = sfAuto);
C++
void __fastcall LoadFromStream(System::Classes::TStream* AStream, Firedac::Stan::Intf::TFDStorageFormat AFormat = (Firedac::Stan::Intf::TFDStorageFormat)(0x0));
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
procedure function |
public | FireDAC.Comp.DataSet.pas FireDAC.Comp.DataSet.hpp |
FireDAC.Comp.DataSet | TFDDataSet |
Description
Loads a dataset's data from a stream.
Use LoadFromStream to populate the dataset with data stored in an external file. The data is not moved to a database, but just loaded into a dataset in-memory storage.
AStream
is the reference to the stream, containing the data to load. The stream position must be at beginning of the dataset data, otherwise the loading fails.
AFormat
is the file format:
sfXML
– a stream contains well formed stand-alone XML data.sfBinary
– a stream contains binary data with custom FireDAC format.sfAuto
– a format is determined by ResourceOptions.sfJSON
– a stream contains stand-alone JSON data.
DefaultStoreExt if it is specified, otherwise by ResourceOptions.DefaultStoreFormat.
LoadFromStream tries to load from the stream the items specified by ResourceOptions.StoreItems. If the stream was written with a different StoreItems value, then an exception like the following is raised:
[FireDAC][Stan]-712 Cannot read [Relationlist] object
Example
var
oStr: TStream;
....
oStr := FDQuery1.CreateBlobStream(FDQuery1.FieldByName('data'), bmRead);
try
FDMemTable1.LoadFromStream(oStr, sfBinary);
finally
oStr.Free;
end;