Choosing the Type of Dataset for Caching Updates
Go Up to Using a Client Dataset to Cache Updates
Delphi includes some specialized client dataset components for caching updates. Each client dataset is associated with a particular data access mechanism. These are listed in the following table:
Specialized client datasets for caching updates :
Client dataset | Data access mechanism |
---|---|
dbExpress | |
DBLocalI.TIBClientDataSet |
InterBase Express |
Generic client dataset for caching updates :
Client dataset | Data access mechanism |
---|---|
dbExpress, dbGo, BDE |
You can cache updates using the generic client dataset (Using a client dataset with a provider).
Note: The specialized client datasets associated with each data access mechanism actually use a provider and source dataset as well. However, both the provider and the source dataset are internal to the client dataset.
It is simplest to use one of the specialized client datasets to cache updates. However, there are times when it is preferable to use TClientDataSet with an external provider:
- If you are using a data access mechanism that does not have a specialized client dataset, you must use TClientDataSet with an external provider component. For example, if the data comes from an XML document or custom dataset.
- If you are working with tables that are related in a master/detail relationship, you should use TClientDataSet and connect it, using a provider, to the master table of two source datasets linked in a master/detail relationship. The client dataset sees the detail dataset as a nested dataset field. This approach is necessary so that updates to master and detail tables can be applied in the correct order.
- If you want to code event handlers that respond to the communication between the client dataset and the provider (for example, before and after the client dataset fetches records from the provider), you must use TClientDataSet with an external provider component. The specialized client datasets publish the most important events for applying updates (OnReconcileError, BeforeUpdateRecord and OnGetTableName), but do not publish the events surrounding communication between the client dataset and its provider, because they are intended primarily for multi-tiered applications.