CancelUpdate - method of the AdoRecordset object
Description:
It is used for ending the edit mode and
cancelling all modifications of the current record. The edit mode was started either by the
AddNew method (in this case the new record is cancelled) or by writing the values into the current record (record editing).
Syntax:
Empty CancelUpdate()
Example:
Adds a new record into the table (
"table1") and modifying the contents of the new record, using the stored
AdoRecordset object (
"table1"), in the
PmaAdo object (
"/TestAdoDb"), that is already connected to the database (see the
DbOpen method), by means of the SQL query (
"SELECT * FROM table1"). At the end, the adding of a new record is not confirmed by the
Update method, but cancelled by the
CancelUpdate method.
JavaScriptVBScriptSelect and copy to clipboard
var oDb = pMe.Pm("/TestAdoDb");
var oRs = oDb.RsOpen("table1", "SELECT * FROM table1", "cursor:static;lock:optimistic;");
if (oRs)
{
oRs.AddNew();
oRs.Fields.Item("name").Value = "pi";
oRs.Fields.Item("value").Value = 3.14;
oRs.CancelUpdate();
}
Dim oDb
Set oDb = pMe.Pm("/TestAdoDb")
Dim oRs
Set oRs = oDb.RsOpen("table1", "SELECT * FROM table1", "cursor:static;lock:optimistic;")
If Not oRs Is Nothing Then
oRs.AddNew
oRs.Fields.Item("name").Value = "pi"
oRs.Fields.Item("value").Value = 3.14
oRs.CancelUpdate
End If