Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>An ADO.Net Dataset uses Optimistic Concurrency by default. If an attempt is made to update a row to the database when the row no longer exists in the database then the result is the error: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.</p> <p>Here is the scenario where that error can occur. </p> <pre><code>// data row has been added DataRow dr= null; dtTab = (DataTable)Session("dtTab"); dr = dtTab.Rows(e.RowIndex); dr.Delete(); dtTab.AcceptChanges(); // If Acceptchanges() being not called, row status will be //detached, that will not be updated to database. //Without updating database Acceptchanges() called.Row status //changed to deleted. If this update to database, // it will give concurrency error- // because row no longer exist in database. </code></pre> <p>The reason for the error became apparent. The records in the row in the table didn't exist in the database. However, the DeleteCommand was trying to remove them from the Database. And when the data adapter class attempts to delete a record and doesn't see any rows being changed, it assumes that a concurrency violation has occured. </p> <blockquote> <p>Here is the <a href="http://www.c-sharpcorner.com/uploadfile/cf9547/error-system-data-dbconcurrencyexception-concurrency-violation-the-updatecommand-affected-0-of-th/" rel="nofollow">artcile</a> (The Source of above code) regarding the issue. This article describe when the DBConcurrencyException will raised and how to solve the problem. Please go through the artcicle.</p> <p><strong>Please try the same things with store procedure, may this will help you.</strong></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload