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 |
TBDEClientDataSet |
Borland Database Engine |
TSimpleDataSet |
dbExpress |
TIBClientDataSet |
InterBase Express |
In addition, you can cache updates using the generic client dataset (TClientDataSet) with an external provider and source dataset. For information about using TClientDataSet with an external provider, see 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.
- When using the BDE, you may want to use an external provider and source dataset if you need to use an update object. Although it is possible to code an update object from the BeforeUpdateRecord event handler of TBDEClientDataSet, it can be simpler just to assign the UpdateObject property of the source dataset. For information about using update objects, see Using update objects to update a dataset.