C# Delete Problem

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?
 
G

Guest

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top