virtual BOOL Update( );
throw( CDBException );
Return Value
Nonzero if one record was successfully updated; otherwise 0 if no columns have changed. If no records were updated, or if more than one record was updated, an exception is thrown. An exception is also thrown for any other failure on the data source.
Remarks
Call this member function after a call to the AddNew or Edit member function. This call is required to complete the AddNew or Edit operation.
Note If you have implemented bulk row fetching, you cannot call Update. This will result in a failed assertion. Although class CRecordset does not provide a mechanism for updating bulk rows of data, you can write your own functions by using the ODBC API function SQLSetPos. For an example of how to do this, see the sample DBFETCH. For more information about bulk row fetching, see the article Recordset: Fetching Records in Bulk (ODBC) in Visual C++ Programmer’s Guide.
Both AddNew and Edit prepare an edit buffer in which the added or edited data is placed for saving to the data source. Update saves the data. Only those fields marked or detected as changed are updated.
If the data source supports transactions, you can make the Update call (and its corresponding AddNew or Edit call) part of a transaction. For more information about transactions, see the article Transaction (ODBC) in Visual C++ Programmer’s Guide.
Caution If you call Update without first calling either AddNew or Edit, Update throws a CDBException. If you call AddNew or Edit, you must call Update before you call a Move operation or before you close either the recordset or the data source connection. Otherwise, your changes are lost without notification.
For details on handling Update failures, see the article Recordset: How Recordsets Update Records (ODBC) in Visual C++ Programmer’s Guide.
Example
See the article Transaction: Performing a Transaction in a Recordset (ODBC) in Visual C++ Programmer’s Guide.
CRecordset Overview | Class Members | Hierarchy Chart
See Also CRecordset::Edit, CRecordset::AddNew, CRecordset::SetFieldDirty, CDBException