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

Started by
2 comments, last by manuelb 18 years, 6 months ago
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.
--------------------------Rory Gallagher and Chico Science music !!!!!!!---------------------------____||~~~~|/TT
Advertisement
No reply? It's crazy, I thought a lot of people was using System.Data namespace from .NET framework... :)
--------------------------Rory Gallagher and Chico Science music !!!!!!!---------------------------____||~~~~|/TT
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.
- k2"Choose a job you love, and you'll never have to work a day in your life." — Confucius"Logic will get you from A to B. Imagination will get you everywhere." — Albert Einstein"Money is the most egalitarian force in society. It confers power on whoever holds it." — Roger Starr{General Programming Forum FAQ} | {Blog/Journal} | {[email=kkaitan at gmail dot com]e-mail me[/email]} | {excellent webhosting}
Thank's
--------------------------Rory Gallagher and Chico Science music !!!!!!!---------------------------____||~~~~|/TT

This topic is closed to new replies.

Advertisement