My DataAdapter.UpdateCommand calls a stored procedure that does other things beyond just updating the current record (deleting related records, for example). The rows affected by my stored procedure can be zero because of this, triggering the following error:

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records

I know I can trap the error, but I would prefer to set ADO.Net to not check for concurrency violations in specific cases.

有帮助吗?

解决方案

Here's a hack I came up with for now. I modified the last statement in my stored procedure to be this:

--hack to force @@ROWCOUNT to be 1. needed for ado.net concurrency violation check
DECLARE @Hack BIT; SELECT @Hack = 0;

It makes @@ROWCOUNT 1, but does not return another table.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top