Determining the Source of Data
Go Up to Using Provider Components Index
When you use a provider component, you must specify the source it uses to get the data it assembles into data packets. Depending on your version of Delphi, you can specify the source as one of the following:
- To provide the data from a dataset, use Datasnap.Provider.TDataSetProvider.
- To provide the data from an XML document, use Datasnap.Xmlxform.TXMLTransformProvider.
Using a dataset as the source of the data
If the provider is a dataset provider (TDataSetProvider), set the DataSet property of the provider to indicate the source dataset. At design time, select from available datasets in the DataSet property drop-down list in the Object Inspector.
TDataSetProvider interacts with the source dataset using the Data.DB.IProviderSupport interface. This interface is introduced by TDataSet, so it is available for all datasets. However, the IProviderSupport methods implemented in TDataSet are mostly stubs that do not do anything or that raise exceptions.
The dataset classes that ship with Delphi (BDE-enabled datasets, ADO-enabled datasets, dbExpress datasets, and InterBase Express datasets) override these methods to implement the IProviderSupport interface in a more useful fashion. Client datasets do not add anything to the inherited IProviderSupport implementation, but can still be used as a source dataset as long as the ResolveToDataSet property of the provider is True.
Component writers that create their own custom descendants from TDataSet must override all appropriate IProviderSupport methods if their datasets are to supply data to a provider. If the provider only provides data packets on a read-only basis (that is, if it does not apply updates), the IProviderSupport methods implemented in TDataSet may be sufficient.
Using an XML document as the source of the data
If the provider is an XML provider, set the XMLDataFile property of the provider to indicate the source document.
XML providers must transform the source document into data packets, so in addition to indicating the source document, you must also specify how to transform that document into data packets. This transformation is handled by the provider TransformRead property. TransformRead represents a TXMLTransform object. You can set its properties to specify what transformation to use, and use its events to provide your own input to the transformation. For more information on using XML providers, see Using an XML document as the source for a provider.