RAD Studio |  |

Saving Data to a File or Stream
See Also
Collapse All

Even when you have merged changes into the data of a client dataset, this data still exists only in memory. While it persists if you close the client dataset and reopen it in your application, it will disappear when your application shuts down. To make the data permanent, it must be written to disk. Write changes to disk using the SaveToFile method.

SaveToFile takes one parameter, a string that specifies the file into which to write data. The file name can be a fully qualified path name, if appropriate. If the file already exists, its current contents are completely overwritten.

Note: SaveToFile does not preserve any indexes you added to the client dataset at runtime, only indexes that were added when you created the client dataset.
If you always save the data to the same file, you can use the FileNameproperty instead. If FileName is set, the data is automatically saved to the named file when the client dataset is closed.

You can also save data to a stream, using the SaveToStream method. SaveToStream takes one parameter, a stream object that receives the data.

Note: If you save a client dataset while there are still edits in the change log, these are not merged with the data. When you reload the data, using the LoadFromFile or LoadFromStream method, the change log will still contain the unmerged edits. This is important for applications that support the briefcase model, where those changes will eventually have to be applied to a provider component on the application server.
See Also

Creating a New Dataset

Merging Changes into Data

Loading Data from a File or Stream

Using the Briefcase Model

Sorting and Indexing

Editing Data

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!