RowState

?

?scar Martins

Hi

I have a datable that is linked to a db table. When I delete an
unchanged row and then add a new row with the same values my datatable
stays with a deleted and an added row identical in values. When I
commit the changes into db by Dataadapter.Update is executed a delete
and then one update, although the data remains the same. The
problem/behaviour is that if the table has a relation to other table
and this row has childrows when is deleted it throws an exception and
the update is canceled. This is right, but in the user optic he has
changed nothing and receives a message that he can't delete that row.
What's the best way to deal with this situation?

Thanks in advance
 
W

W.G. Ryan eMVP

You can call update based solely on Rowstate - So first you could just call
Update using the deleted child rows to remove the data from the child table.
Then you can call update on the parent w/ just the Deleted rows. Then Update
with the added and/or modified rows. This should make things sync with the
back end db.

You can actually fix the probelm by calling update on the child table first
and then the parent but I mention the more granular updates just to give you
a feel for how tightly you can control things.
 

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