.
procedure SaveToFile(const FileName: string; Format: TdataPacketFormat);
In the above method the 'FileName' parameter refers to the name of the file to which you want to save data and with the 'Format' parameter you can specify the format you want the file saved in. This could be binary (dfBinary) or XML (dfXML), or UTF8-based XML (dfXMLUTF8). The file is saved with a .cds extension or a .xml extension depending on what you specify in the method.
Although both parameters in the above method are optional, you need to provide it with a file name in which you wish to save data, as if the dataset's filename property has not already been assigned a value. If a filename has been specified, data is saved in a file bearing that name.
If you omit the second parameter, data is saved in the native format of the file type you chose to save it as. This means that if you assigned a filename with a .xml extension to the filename property of the dataset or specified the first parameter as a filename with .xml extension, the data will be stored in XML format. For any other extension, data will be saved in binary format. However, if you want to save data as XML but want to save the file with a different extension you can use the Format parameter of the SaveToFile method.
Do remember that if you have specified a value to the filename property of the client dataset, you need to deploy the file along with the application (along with midas.dll). Also remember that you don't need to call the LoadFromFile and SaveToFile routines, the client dataSet will load data from the file specified in its filename property when it is opened and will save data to the file when it is closed.
The client dataSet is a non-visual component, which means that neither the data nor the component itself is visible during runtime, but we can design a very simplistic front end interface using data-aware controls to display data held in the dataset. Drop a TDataSource component and set its dataset property to point to the client dataset. Next drop a TDBGrid component and set its data source property to the data source component we just added, namely DBGrid. Set the active property of the client dataset to true. You should now be able to view the data in the DBGrid component. To navigate and edit, add a TDBNavigator and link it to data source component.
We now have a fully functional database application that saves data to a flat file. In the next installment we will look at using the client dataset with a dataset provider in a two-tiered application architecture.