Refreshing datagridview contents after a failed delete in bound datagridview

B

Bob

I have relational integrity set up in my sql server 2005 database that
prevents cascading deletes in some cases.
I'm using a bound datagrid view and a tablenavigator. When I click the
delete button on it then the save button, I get the message saying a foreign
key constraint does not allow the deletion, but the row is no longer shown
in the datagridview. Only way I get to see it is to close my form and open
it again, then row is there OK.

Question is how do I refresh the datagridview after such a failed delete.

I can think of doing the checking to see if there are any child records in
the UI code UserDeletingRows event of the datagrid, then issuing a Cancel so
that the UI prevents the deletion, but that sort of circumvents the purpose
of letting your database doing the integrity checking.

Can anyone give me an idea on how to detect that a delete has failed using
these controls , I know how to do a refill. I just need to know what event
to use to launch it.

Any help appreciated,

Bob
 

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