PRB: Unable to Delete from Table Having Cascade Delete Trigger (194981)
The information in this article applies to:
- ActiveX Data Objects (ADO) 2.0
- ActiveX Data Objects (ADO) 2.1 SP2
- ActiveX Data Objects (ADO) 2.5
- ActiveX Data Objects (ADO) 2.6
- ActiveX Data Objects (ADO) 2.7
This article was previously published under Q194981 SYMPTOMS Deleting a record from a SQL Server table with a cascade
delete trigger causes the following error message when there are no matching
rows in the child table if the OLE DB provider is used for SQL Server:
-2147217864 The specified row could not be located for
updating: Some values may have been changed since it was last read.
CAUSE The only way that the Client Cursor Engine can determine
whether the update succeeded is by interpretation of the return code from the
provider's ICommand::Execute. If the execution returns a failure code, the
update is presumed to have failed.
In the preceding case, the
trigger is disguising the results of the original operation. The row count for
the SECOND delete is being returned as the [pcRowsAffected] for the original
delete in the Cursor Engine's call to ICommand::Execute. Since the Cursor
Engine is told that zero (0) rows were affected by the DELETE call, it
concludes that there was a concurrency violation and causes the error to
display. RESOLUTION You have to explicitly add "SET NOCOUNT ON" in the trigger
to prevent it from returning the "0 rows affected" message to the Sqloledb
provider's cursor engine. The cursor engine interprets the "0 rows affected" to
mean the delete failed. STATUS This behavior is by design.
Modification Type: | Minor | Last Reviewed: | 3/14/2005 |
---|
Keywords: | kbBug kbDatabase kbpending kbprb kbStoredProc KB194981 |
---|
|