Concurrency violation: the UpdateCommand affected 0 of the expected 1 records Access Database

Hobbyist_programmer 621 Reputation points
2022-07-06T17:47:49.783+00:00

Hallo,

I have an access database bound to the data grid view using a binding source. I edit my row and try to update the database, but I'm getting a Concurrency violation error. Please help.

Using conn As New OleDbConnection(ConnStr)  

                Dim selectCommand As New OleDbCommand(CmdStrEqp, conn)  
                Dim da As New OleDbDataAdapter(selectCommand)   
 
                Dim cb As New OleDb.OleDbCommandBuilder(da)  
                cb.QuotePrefix = "["  
                cb.QuoteSuffix = "]"  
  
                da.Update(DS.Tables("Project"))  
                DS.Tables("Project").AcceptChanges()                 
  
 End Using  

Thanks

Developer technologies | VB
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    2022-07-07T02:12:53.62+00:00

    Hi @Hobbyist_programmer
    A concurrency error occurs when the data you're trying to update has already been updated between the time you got the data you were changing and the time you're trying to execute your update.
    It is recommended that you step through to see which step in your code is causing this data problem.
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.