|
Indicates the status of the current record with respect to batch updates or other bulk operations.
Returns a sum of one or more of the following RecordStatusEnum values:
Constant |
Description |
adRecOK |
The record was successfully updated. |
adRecNew |
The record is new. |
adRecModified |
The record was modified. |
adRecDeleted |
The record was deleted. |
adRecUnmodified |
The record was not modified. |
adRecInvalid |
The record was not saved because its bookmark is invalid. |
adRecMultipleChanges |
The record was not saved because it would have affected multiple records. |
adRecPendingChanges |
The record was not saved because it refers to a pending insert. |
adRecCanceled |
The record was not saved because the operation was canceled. |
adRecCantRelease |
The new record was not saved because of existing record locks. |
adRecConcurrencyViolation |
The record was not saved because optimistic concurrency was in use. |
adRecIntegrityViolation |
The record was not saved because the user violated integrity constraints. |
adRecMaxChangesExceeded |
The record was not saved because there were too many pending changes. |
adRecObjectOpen |
The record was not saved because of a conflict with an open storage object. |
adRecOutOfMemory |
The record was not saved because the computer has run out of memory. |
adRecPermissionDenied |
The record was not saved because the user has insufficient permissions. |
adRecSchemaViolation |
The record was not saved because it violates the structure of the underlying database. |
adRecDBDeleted |
The record has already been deleted from the data source. |
Use the Status property to see what changes are pending for records modified during batch updating. You can also use the Status property to view the status of records that fail during bulk operations such as when you call the ADO Recordset Object Resync Method, ADO Recordset Object UpdateBatch Method, or ADO Recordset Object CancelBatch Method methods on a Recordset object, or set the ADO Recordset Object Filter Property on a Recordset object to an array of bookmarks. With this property, you can determine how a given record failed and resolve it accordingly.
This example uses the Status property to display which records have been modified in a batch operation before a batch update has occurred.
Public Sub StatusX()
Dim rstTitles As ADODB.Recordset
Dim strCnn As String
` Open recordset for batch update.
strCnn = "driver={SQL Server};server=srv;" & _
"uid=sa;pwd=;database=pubs"
Set rstTitles = New ADODB.Recordset
rstTitles.CursorType = adOpenKeyset
rstTitles.LockType = adLockBatchOptimistic
rstTitles.Open "titles", strCnn, , , adCmdTable
` Change the type of psychology titles.
Do Until rstTitles.EOF
If Trim(rstTitles!Type) = "psychology" Then
rstTitles!Type = "self_help"
End If
rstTitles.MoveNext
Loop
` Display Title ID and status.
rstTitles.MoveFirst
Do Until rstTitles.EOF
If rstTitles.Status = adRecModified Then
Debug.Print rstTitles!title_id & " - Modified"
Else
Debug.Print rstTitles!title_id
End If
rstTitles.MoveNext
Loop
` Cancel the update because this is a demonstration.
rstTitles.CancelBatch
rstTitles.Close
End Sub
Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.