From RAD Studio API Documentation
Jump to: navigation, search


procedure LoadFromFile(const AFileName: String = ''; AFormat: TFDStorageFormat = sfAuto);


void __fastcall LoadFromFile(const System::UnicodeString AFileName = System::UnicodeString(), Firedac::Stan::Intf::TFDStorageFormat AFormat = (Firedac::Stan::Intf::TFDStorageFormat)(0x0));


Type Visibility Source Unit Parent
FireDAC.Comp.DataSet TFDDataSet


Loads a dataset's data from a file.

Use LoadFromFile to populate the dataset with data stored in an external file. The data is not moved to a database, it is just loaded into a dataset in-memory storage. 

AFileName is the name of the file containing the data to load. If the file does not exist, an exception is raised. 

AFormat is the file format:

  • sfXML – a well formed stand-alone XML file.
  • sfBinary – a binary file with custom FireDAC format.
  • sfAuto – a format is determined by the AFileName extention: ".XML" - XML file, ".ADB" / ".BIN" / ".DAT" * sfAuto – binary file.
  • sfJSON – a stand-alone JSON file.

If AFileName does not have an extension, the format is determined by ResourceOptions.DefaultStoreExt if it is specified. Otherwise, it is determined by ResourceOptions.DefaultStoreFormat.

Optionally, you can specify ResourceOptions.PersistentFileName and call Open, and dataset data is loaded from the specified file. When calling Close, it is saved back if data was modified. 

AFileName must contain data saved to a file by a previous call to this or another client dataset's SaveToFile method. After the call, the dataset is active. 

LoadFromFile tries to load from the file the items specified by ResourceOptions.StoreItems. If the file was written with a different StoreItems value, the following exception is raised: 

  [FireDAC][Stan]-712 Cannot read [Relationlist] object


FDQuery1.Open('select * from customers');
FDQuery1.SaveToFile('c:\customers.xml', sfAuto);
FDMemTable1.LoadFromFile('c:\customers.xml', sfAuto);
FDMemTable1.Locate('CUSTOMER_ID', [100], []);

See Also