When more than one base table referenced in the update dataset needs to be updated, you need to use multiple update objects: one for each base table updated. Because the dataset component's UpdateObject only allows one update object to be associated with the dataset, you must associate each update object with a dataset by setting its DataSet property to the name of the dataset.
UpdateSQL1.DataSet := Query1;
UpdateSQL1->DataSet = Query1;
The update object uses this dataset to obtain original and updated field values for parameter substitution and, if it is a BDE-enabled dataset, to identify the session and database to use when applying the updates. So that parameter substitution will work correctly, the update object's DataSet property must be the dataset that contains the updated field values. When using the BDE-enabled dataset to cache updates, this is the BDE-enabled dataset itself. When using a client dataset, this is a client dataset that is provided as a parameter to the BeforeUpdateRecord event handler.
When the update object has not been assigned to the dataset's UpdateObject property, its SQL statements are not automatically executed when you call ApplyUpdates. To update records, you must manually call the update object from an OnUpdateRecord event handler (when using the BDE to cache updates) or a BeforeUpdateRecord event handler (when using a client dataset). In the event handler, the minimum actions you need to take are
Name |
Description |
The Apply method for an update component manually applies updates for the current record. There are two steps involved in this process:
Warning: If you use the dataset's UpdateObject property to associate dataset and update object, Apply is called... more | |
When you use multiple update objects, you do not associate the update objects with a dataset by setting its UpdateObject property. As a result, the appropriate statements are not automatically executed when you apply updates. Instead, you must explicitly invoke the update object in code. There are two ways to invoke the update object. Which way you choose depends on whether the SQL statement uses parameters to represent field values:
|
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|