MDAC 2.5 SDK - ADO


 

Update Method

See Also    Example    Applies To

Saves any changes you make to the current row of a Recordset object, or the Fields collection of a Record object.

Syntax

recordset.Update Fields, Values

record.Fields.Update

Parameters

Fields   Optional. A Variant that represents a single name, or a Variant array that represents names or ordinal positions of the field or fields you wish to modify.

Values   Optional. A Variant that represents a single value, or a Variant array that represents values for the field or fields in the new record.

Remarks

Recordset

Use the Update method to save any changes you make to the current record of a Recordset object since calling the AddNew method or since changing any field values in an existing record. The Recordset object must support updates.

To set field values, do one of the following:

When you use arrays of fields and values, there must be an equal number of elements in both arrays. Also, the order of field names must match the order of field values. If the number and order of fields and values do not match, an error occurs.

If the Recordset object supports batch updating, you can cache multiple changes to one or more records locally until you call the UpdateBatch method. If you are editing the current record or adding a new record when you call the UpdateBatch method, ADO will automatically call the Update method to save any pending changes to the current record before transmitting the batched changes to the provider.

If you move from the record you are adding or editing before calling the Update method, ADO will automatically call Update to save the changes. You must call the CancelUpdate method if you want to cancel any changes made to the current record or discard a newly added record.

The current record remains current after you call the Update method.

If the Unique Table dynamic property is set, and the Recordset is the result of executing a JOIN operation on multiple tables, then the Update method cannot update any primary key of the multiple tables. Furthermore, the Update method can update fields only in the table specified in the Unique Table property.

Record

The Update method finalizes additions, deletions, and updates to fields in the Fields collection of a Record object.

For example, fields deleted with the Delete method are marked for deletion immediately but remain in the collection. The Update method must be called to actually delete these fields from the provider's collection.