When you add a new record to the
DataSet
and apply it to the database the new auto number value is not placed into the row of the
DataSet
.
Now when you call a delete on this row the generated SQL statement has a
WHERE
clause with an invalid auto number value. This means that the row to be deleted cannot be found and the
DBConcurrencyException
exception is thrown.
To solve this you need to retrieve the assigned auto number and store it in the
DataSet
row. Do this in your save function
btnSave_Click
after the
da.Update(ds1, "Workers");
statement.
Have a look at
this[
^] on how to retrieve the new auto number value.