CancelUpdate Method

See Also    Example    Applies To

Cancels any pending updates for a Recordset object.

Syntax

VOIDCancelUpdate(short sType = dbUpdateRegular);

Parameters

Type Example Description
SHORT sType = dbUpdateRegular Optional. A constant indicating the type of update (ODBCDirect workspaces only).

Settings

You can use the following values for the sType argument only if batch updating is enabled.

Constant Description
dbUpdateRegular Default. Cancels pending changes that aren’t cached.
DbUpdateBatch Cancels pending changes in the update cache.

Remarks

You can use the CancelUpdate method to cancel any pending updates resulting from an Edit or AddNew operation. For example, if a user invokes the Edit or AddNew method and hasn't yet invoked the Update method, CancelUpdate cancels any changes made after Edit or AddNew was invoked.

Check the EditMode property of the CdbRecordset to determine if there is a pending operation that can be canceled.

Note Using the CancelUpdate method has the same effect as moving to another record without using the Update method, except that the current record doesn't change, and various properties, such as BOF and EOF, aren't updated.

Usage

#include <afxole.h>
#include <dbdao.h>
...
BOOL            bOK = TRUE;
CdbRecordset      rst;
...
rst.AddNew();            // Begin to add a record
if (bOK)               // Is it OK to add a record?
   rst.Update();         // yes: Complete the addition
else                  // no: Abort the addition
   rst.CancelUpdate(dbUpdateRegular);