Overriding the Dataset On the Application Server
Go Up to Using client datasets Index
The client datasets that are associated with a particular data access mechanism use the CommandText and CommandType properties to specify the data they represent. When using TClientDataSet, however, the data is specified by the source dataset, not the client dataset. Typically, this source dataset has a property that specifies an SQL statement to generate the data or the name of a database table or stored procedure.
If the provider allows, TClientDataSet can override the property on the source dataset that indicates what data it represents. That is, if the provider permits, the client dataset's CommandText property replaces the property on the provider's dataset that specifies what data it represents. This allows TClientDataSet to specify dynamically what data it wants to see.
By default, external provider components do not let client datasets use the CommandText value in this way. To allow TClientDataSet to use its CommandText property, you must add poAllowCommandText to the Options property of the provider. Otherwise, the value of CommandText is ignored.
Note: Never remove poAllowCommandText from the Options property of TBDEClientDataSet or TIBClientDataSet. The client dataset's Options property is forwarded to the internal provider, so removing poAllowCommandText prevents the client dataset from specifying what data to access.
The client dataset sends its CommandText string to the provider at two times:
- When the client dataset first opens. After it has retrieved the first data packet from the provider, the client dataset does not send CommandText when fetching subsequent data packets.
- When the client dataset sends an Execute command to provider.
To send an SQL command or to change a table or stored procedure name at any other time, you must explicitly use the IAppServer interface that is available as the AppServer property. This property represents the interface through which the client dataset communicates with its provider.
- Specifying a Provider
- Requesting Data from the Source Dataset or Document
- Passing Parameters to the Source Dataset
- Getting Parameters from the Application Server
- Handling Constraints from the Server
- Refreshing Records
- Communicating with Providers Using Custom Events