Objective Grid: Preventing database record writing when a row is updated

Article ID: 308
Last updated: 11 Jun, 2018
Article ID: 308
Last updated: 11 Jun, 2018
Revision: 3
Views: 1732
Posted: 11 Jan, 2001
by Meltreger B.
Updated: 11 Jun, 2018
by Meltreger B.

Problem


Is there an ability to prevent a record from being written to the database whenever a row is updated or inserted in the database?


Cause



Action


You should override OnFlushRecord(). OnFlushRecord() is called whenever a record should be updated or added to the recordset.

By overriding OnFlushRecord(), you can validate all records contents at record level. Objective Grid will always call OnFlushRecord() before it tries to position the current cell to a new row.

If the data in the current record are invalid, you should return FALSE. Objective Grid will then abort its current operation and not try to move the record pointer to a new row any more.

Example:

BOOL CMyRecordGrid::OnFlushRecord(ROWCOL nRow, CString* ps)
{
// check if current record is valid
if (!IsValidRecord())
return FALSE;
// else
return CGXODBCGrid::OnFlushRecord(nRow, ps);
}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 308
Last updated: 11 Jun, 2018
Revision: 3
Views: 1732
Posted: 11 Jan, 2001 by Meltreger B.
Updated: 11 Jun, 2018 by Meltreger B.

Others in this category