Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top