문제

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