skip to content »

Validating descriptive databases

It's a good practice to validate data prior to sending updates to the underlying database.

validating descriptive databases-88

Otherwise, use the Row Changing event, which might result in catching several errors at once.Because the dataset is part of your application (unlike the database backend), it's a logical place to build application-specific validation.The best place to add validation to your application is in the dataset's partial class file.You can validate data when the value in a data column changes by responding to the Column Changing event.When raised, this event passes an event argument (Proposed Value) that contains the value that's being proposed for the current column.If you want to get specific records — for example, only new records or only modified records — you can pass a value from the Data Row State enumeration as a parameter to the Passing the Data Row Version value along with the column index (or column name as a string) returns the value from that column's particular row version.

The changed column is identified during the Column Changing and Column Changed events.

The data row's Begin Edit method turns off the Row Changing and Row Changed events after each individual column change.

In that case, the event is not raised until the End Edit method has been called, when the Row Changing and Row Changed events are raised just once.

Based on the contents of You can write code to verify that each column you want to validate contains data that meets the requirements of your application.

Do this by setting the column to indicate that it contains an error if a proposed value is unacceptable.

If you have not called the Begin Edit method, the Row Changing event is raised for each change to a column immediately after the Column Changing event has been raised.