C# Delete Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Using Datagridview databound:

If I add two rows with data, save (using navigator), refesh that dataset,
then delete the two newly added rows, then Save, everythign is OK.

if I add two rows with data, save (using navigator), then delete those two
rows, then save (using navigator), I get an error that "Concurrency Violation
- The DeleteCommand affected 0 of the expected 1 records. If I then refresh
the dataset, the two rows are still present.

I need to allow user to add and delete rows before saving the dataset back
to the database.

Any ideas?
 
Hi Chris,
I think the problem is in the InsertCommand, presuming the table has an
identity column.
When you add those 2 rows and save, the InsertCommand should assign the
value of the new identity back to the DataColumn of the added row. So, if
this is not happening, then the row has no valid identity, so when you try to
do a delete (by key, identity) it executes the DeleteCommand with wrong
parameters (not affecting any real row).

Sincerely,
 
Back
Top