Jump to content
  • Advertisement
Sign in to follow this  
manuelb

How can I validate row deletion in c# using dataview???

This topic is 4651 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm developing an automation system using Visual Studio .net. First, I found .net framework very user frendly, very intuitive, strongly OO and very nice to program with. But sometimes I get angry with persistent data handling. I'm new to .NET, but since I've programmed in a lot of diferent languages before, I thought it would be easy. Well, it is easy, except System.Data namespace. For example, I'm using a databank that does't have integrity constraints. To validate delection, for example, I thougth I should find the corresponding event on dataview, search the foreing key, and then, cancel deleting if the key is found. Then I found the RowDeleting event... but didn't worked. I can't cancel the deletion there. I searched the internet, and I found this: http://dotnet247.com/247reference/msgs/5/28321.aspx So, it's not possible to that there... Well, and tried RowDelete too, but it's not the best solution, because I don't want to rollback all the changes at the row, but JUST cancel deleting.... What's the best way to do this? Probably, there is a easy e obvius way to do it, but I can't find. Thanks in advance, and sorry for my English.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by manuelb
So, it's not possible to that there... Well, and tried RowDelete too, but it's not the best solution, because I don't want to rollback all the changes at the row, but JUST cancel deleting....
What's the best way to do this?

Before RowDeleting occurs, RowUpdating occurs (see here). Capture the RowUpdating event. If this row should be skipped (perform your validation) and it's a deletion (check the event arguments to see if it's StatementType.Delete), then set the UpdateStatus parameter to SkipCurrentRow. This cancels processing for that row.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!