Delete 方法(ADO 记录集)Delete Method (ADO Recordset)

删除当前记录或一组记录。Deletes the current record or a group of records.

语法Syntax

  
recordset.Delete AffectRecords  

参数Parameters

AffectRecordsAffectRecords
AffectEnum值,用于确定 Delete 方法将影响的记录数。An AffectEnum value that determines how many records the Delete method will affect. 默认值为 adAffectCurrentThe default value is adAffectCurrent.

备注

adAffectAlladAffectAllChapters 不是要 删除 的有效参数。adAffectAll and adAffectAllChapters are not valid arguments to Delete.

备注Remarks

使用 Delete 方法将当前记录或记录 对象中的一组记录标记为删除。Using the Delete method marks the current record or a group of records in a Recordset object for deletion. 如果 记录集 对象不允许删除记录,则会发生错误。If the Recordset object doesn't allow record deletion, an error occurs. 如果处于立即更新模式,则会立即删除数据库中的删除操作。If you are in immediate update mode, deletions occur in the database immediately. 如果由于数据库完整性冲突而无法成功删除记录 (例如) ,则在调用 Update后,该记录将继续处于编辑模式。If a record cannot be successfully deleted (due to database integrity violations, for example), the record will remain in edit mode after the call to Update. 这意味着,必须先取消带有 CancelUpdate 的更新,然后才能将当前记录移 (例如,具有 CloseMoveNextRecordset) 。This means that you must cancel the update with CancelUpdate before moving off the current record (for example, with Close, Move, or NextRecordset).

如果处于批处理更新模式,记录将标记为从缓存中删除,并且在调用 UpdateBatch 方法时会发生实际的删除。If you are in batch update mode, the records are marked for deletion from the cache and the actual deletion happens when you call the UpdateBatch method. 使用 " 筛选器 " 属性查看已删除的记录。Use the Filter property to view the deleted records.

从已删除记录中检索字段值将生成错误。Retrieving field values from the deleted record generates an error. 删除当前记录后,删除的记录将保持当前状态,直到您移到另一记录为止。After deleting the current record, the deleted record remains current until you move to a different record. 离开删除的记录后,它将无法再访问。Once you move away from the deleted record, it is no longer accessible.

如果在事务中嵌套删除,则可以使用 RollbackTrans 方法恢复已删除的记录。If you nest deletions in a transaction, you can recover deleted records with the RollbackTrans method. 如果处于批处理更新模式,可以使用 CancelBatch 方法取消挂起的删除或挂起的删除组。If you are in batch update mode, you can cancel a pending deletion or group of pending deletions with the CancelBatch method.

如果由于与基础数据发生冲突而导致删除记录的尝试失败 (例如,其他用户) 已删除记录,则该提供程序会将警告返回到 错误 集合,但不会暂停程序执行。If the attempt to delete records fails because of a conflict with the underlying data (for example, a record has already been deleted by another user), the provider returns warnings to the Errors collection but does not halt program execution. 仅当所有请求的记录上发生冲突时才会发生运行时错误。A run-time error occurs only if there are conflicts on all the requested records.

如果设置了 " 唯一表 动态" 属性,并且 记录集 是对多个表执行联接操作的结果,则 delete 方法将仅删除 " 唯一表 " 属性中命名的表中的行。If the Unique Table dynamic property is set, and the Recordset is the result of executing a JOIN operation on multiple tables, then the Delete method will only delete rows from the table named in the Unique Table property.

应用于Applies To

记录集对象 (ADO)Recordset Object (ADO)

另请参阅See Also

Delete 方法示例 (VB) Delete Method Example (VB)
(VBScript) 的 Delete 方法示例 Delete Method Example (VBScript)
删除方法示例 (VC + +) Delete Method Example (VC++)
(ADO 字段集合的 Delete 方法) Delete Method (ADO Fields Collection)
(ADO 参数集合的 Delete 方法) Delete Method (ADO Parameters Collection)
DeleteRecord 方法 (ADO)DeleteRecord Method (ADO)