none
Concurrency violation addeding records Why? RRS feed

  • Question

  • Hi,

     

    I'm getting perodic concurrency violations while adding new records, can someone please tell me how to resolve this.   I have an application that is running multi-user, approx 60+ users and for some reason my application is throwing a concurrency violation when adding a new record, I have a bindingsource that is bound to several fields, I then issue a EndEdit() followed by an update.  95% of the time it works and the other 5% I get a concurrency error..    This is very frustrating. the dataset being updated contains an identity field which is an int, I set this identity field using the datasets autoincrement feature and autostep -1.  My insert statement does NOT contain the identity field.

     

    Thanks,

    Friday, November 16, 2007 8:13 PM

All replies

  • Does your table have any triggers defined on it?  If so, make sure that these triggers start with a SET NOCOUNT ON statement.

     

    A common reason for concurrency violations is that a trigger is sometimes returning a 'zero rows affected' message that makes .NET think that the command failed.

     

    Another thing to look for is how the IDENTITY is being returned.  SQL Server has @@IDENTITY and SCOPE_IDENTITY() functions.  @@IDENTITY is susceptible to problems when triggers are involved.  Visual Studio 2005 should generate adapters using SCOPE_IDENTITY(), but previous versions used @@IDENTITY and could cause problems.

    Saturday, November 17, 2007 8:14 PM
  •  

    SET NOCOUNT ON fixed a similar problem I was having... Thanks for the advice. 
    Wednesday, January 16, 2008 3:00 PM
  • A possible reason and solution at the following discussion -

    http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/672152a4-950e-45a3-b7c8-7310529bf61a


    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers.
    Thanks!
    Aalam | Blog (http://aalamrangi.wordpress.com)

    Saturday, June 2, 2012 6:59 PM