Results 1 to 5 of 5

Thread: concurrency violation: The updatecommand affected 0 of the expected 1

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    11

    concurrency violation: The updatecommand affected 0 of the expected 1

    im using a sqldataadapter, dataset and bindingsource to connect to a table. i retrieve all records from the database and i change the data on a field then update changes to database. when i try to change back to original value i get a Concurrency violation error (concurrency violation: The updatecommand affected 0 of the expected 1). this is the code:

    Code:
    1. Try
    2.             Me.Validate()
    3.             Me.sqlBindingSource.EndEdit()
    4.  
    5.             Dim slqCmdBuilder As New SqlCommandBuilder(sqlAdapter)
    6.  
    7.             Me.sqlAdapter.Update(Me.sqlDs.Tables("Items"))
    8.  
    9.             slqCmdBuilder.Dispose()
    10.             slqCmdBuilder = Nothing
    11.  
    12.             Me.sqlBindingSource.ResetBindings(True)
    13.  
    14. Catch ex As Exception
    15.             MessageBox.Show(ex.Message, "Ειδοποίηση", MessageBoxButtons.OK, MessageBoxIcon.Error)
    16. End Try

    can anyone help me plz?

  2. #2
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    Re: concurrency violation: The updatecommand affected 0 of the expected 1

    Are you changing the primary key?
    VB6 Library

    If I helped you then please help me and rate my post!
    If you solved your problem, then please mark the post resolved

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    11

    Re: concurrency violation: The updatecommand affected 0 of the expected 1

    i not changing the primary key nut i think i fihured it out. theres a trigger on my table that automatically updates the last date & time the record is changed. when i create my sqldata adapter i do a "select * from table" which in turn retrieves this record. i think that if i select all fields except this datetime field i soulded have a problem. whats your oppion?

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    11

    Resolved [SOLVED] concurrency violation: The updatecommand affected 0 of the expected 1

    i was right. creating a script without the last update datetime of the record fixed the problem. thnx anyway

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: concurrency violation: The updatecommand affected 0 of the expected 1

    That's a very annoying problem, so it is good that you found such a rational solution.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width