blah blah blah is here! blah blah » Close

up0down
link

I'm trying to update certain records in a database after it's been filtered but get the following error: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

Now the code below is causing the error and there's not a primary key in the database for various reasons - but is there a way to change the saving code to something else?:

this.Validate();
this.tableBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.salesDataSet);


I've tried:

this.salesDataSet.AcceptChanges();


And it still throws the error?

last answered one year ago

1 answers

up0down
link

This seems to be a common problem with the TableAdapter and, as it's a fairly inscrutable error message, it's anybody's guess what causes it.

However, one tip I've seen for solving it is to call the Fill() method after UpdateAll() i.e:

this.tableAdapterManager.UpdateAll(this.salesDataSet);
this.tableAdapterManager.Fill(this.salesDataSet);

So I'd try that.

Feedback