Concurrency violation: the UpdateCommand affected 0 of the expected 1 records. Visual C# 2010

前端 未结 5 1777
走了就别回头了
走了就别回头了 2021-01-14 15:46

i\'m sorry. i wouldn\'t post this if i weren\'t out of ideas. i\'ve tried everything in the forums, but to no avail.

so i have 2 tables. both are empty at the beginn

相关标签:
5条回答
  • 2021-01-14 16:10

    I received this error message because my workstation was set to a different time zone than my server. Once I got it back to the same time zone...problem went away

    0 讨论(0)
  • 2021-01-14 16:15

    I know this thread is old, but I'd like to share the situation in which I got this error in case anyone runs across this also from an internet search.

    I was seeing this error message in a legacy app. It turned out to be a result of a previous programmer coding up some logic that retrieved a DataTable, forcibly removed a column from it, then allowed the user to edit the DataTable in a grid. The DataTable was then passed to the adapter (an OracleDataAdapter in my case) to apply any changes.

    So...manually removing a column from a DataTable before sending it to the SqlDataAdapter can also result in this error message.

    0 讨论(0)
  • 2021-01-14 16:16

    This error is mostly because of updating multiple changes to database without reloading updated data between requests and when you try to save(Update) stacked changes this error may occur.

    For more info check this answer by Henk which was very helpful for me.


    And here there is a good example in details.

    0 讨论(0)
  • 2021-01-14 16:24
    this.contactDBDataSet.AcceptChanges();
    

    That Right !! FIN

    0 讨论(0)
  • 2021-01-14 16:33

    i have the same problem. but i am using Visual studio 2010 with C# and windows form. i solved my problem by placing "this.contactDBDataSet.AcceptChanges(); before "this.tableAdapterManager.UpdateAll(this.contactDBDataSet);". here is the sample.

    private void peopleBindingNavigatorSaveItem_Click_2(object sender, EventArgs e)
    {
        this.Validate();
        this.peopleBindingSource.EndEdit();
        this.contactDBDataSet.AcceptChanges();// added by Humayoo
        this.tableAdapterManager.UpdateAll(this.contactDBDataSet);
    
    
    }
    
    0 讨论(0)
提交回复
热议问题