Using the Client Dataset in File-Based Architecture
A client dataset can be used as a fully functional file-based dataset in a single-tier application as well as the client part of a multi-tiered application. A file-based application is the simplest form of database application, and it does not require a database server to save data in. Instead, it uses MyBase, the ability of client datasets to save themselves to a file and to load the data from a file.
Using the Client Dataset in File-Based Architecture (Page 1 of 4 )
For the purpose of demonstration let us create a very simple application that stores just four fields: first name, last name, phone number and email address. To create and use client datasets in an application that does not require a connection to the database server you can adopt one of the following three approaches.
The easiest approach to working with the client dataset without requiring a persistent server connection is by is copying data to the client dataset from another dataset. During design time this can be done by clicking on the “Assign Local Data”option available in the context menu of the client dataset component. When this option is selected, a list of available datasets is displayed and you can choose the one that contains the data you want to copy.
Well, this is the only time we will be using an external database. Once the data is copied to the client dataset you can delete the external dataset. The data as well as the structure is now contained in the client dataset component.
You can assign data to the client dataset from another data source during runtime by using the data property of the client dataset. To copy data from another client dataset component assign it using both datasets' data property.
However, to copy data from a dataset other than the client dataset, a dataset provider would be required. The dataset provider acts as an intermediary between the two datasets. It points to the dataset which is to be copied through its dataset property and the client dataset links to the dataset provider through its dataset property.
After copying data from the dataset you can delete it and the provider from the application; the client dataset is now self-contained and no longer needs them. When taking this approach you should remember that copying data is different from using the CloneCursor method. When copying data by calling “Assign Data” or using the data property the actual data is copied to the client dataset but when the CloneCursor method is called, the data is shared by the client dataset with the other dataset. Any modification of the data by one dataset is reflected in the other dataset.