RAD Studio
ContentsIndex
PreviousUpNext
Specifying a Provider

Unlike the client datasets that are associated with a data access mechanism, TClientDataSet has no internal provider component to package data or apply updates. If you want it to represent data from a source dataset or XML document, therefore, you must associated the client dataset with an external provider component. 

The way you associate TClientDataSet with a provider depends on whether the provider is in the same application as the client dataset or on a remote application server running on another system.

Provider's location 
How to associate TClientDataSet 
The provider is in the same application as the client dataset  
If the provider is in the same application as the client dataset, you can associate it with a provider by choosing a provider from the drop-down list for the ProviderName property in the Object Inspector. This works as long as the provider has the same Owner as the client dataset. (The client dataset and the provider have the same Owner if they are placed in the same form or data module.) To use a local provider that has a different Owner, you must form the association at runtime using the client dataset's SetProvider method
If you think you may eventually scale up to a remote provider, or if you want to make calls directly to the IAppServer interface, you can also set the ConnectionBroker property to a TLocalConnection component. If you use TLocalConnection, the TLocalConnection instance manages the list of all providers that are local to the application, and handles the client dataset's IAppServer calls. If you do not use TLocalConnection, the application creates a hidden object that handles the IAppServer calls from the client dataset.  
The provider is on a remote application server  
If the provider is on a remote application server, then, in addition to the ProviderName property, you need to specify a component that connects the client dataset to the application server. There are two properties that can handle this task: RemoteServer, which specifies the name of a connection component from which to get a list of providers, or ConnectionBroker, which specifies a centralized broker that provides an additional level of indirection between the client dataset and the connection component. The connection component and, if used, the connection broker, reside in the same data module as the client dataset. The connection component establishes and maintains a connection to an application server, sometimes called a "data broker." For more information, see The structure of the client application
At design time, after you specify RemoteServer or ConnectionBroker, you can select a provider from the drop-down list for the ProviderName property in the Object Inspector. This list includes both local providers (in the same form or data module) and remote providers that can be accessed through the connection component.  

Note: If the connection component is an instance of TDCOMConnection, the application server must be registered on the client machine.
At runtime, you can switch among available providers (both local and remote) by setting ProviderName in code.

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