Checks for Nulls In DataSet Partial Class
Posted on 2006-06-04
I would like to remove validation checks I have in my forms and move them to the DataSet partial class, specifically checks for null entries when a user has not completed the fields in the windows form properly. My database columns do not allow null entries and I have been playing around with the setting "AllowDBNull" on the columns in my DataSet. If I set AllowDBNUll to False then as you would expect I get an error in the Windows Form which I can manage with an event handler, but how do I trap this error at DataSet level instead if I have removed the check in the form ?
I have the following code in my partial class:
partial class DataSet1
partial class CPTY_COMPANYDataTable
protected new void OnTableNewRow(System.Data.DataTableNewRowEventArgs e)
e.Row.RowError.Equals("Code value is required");
It doesn't seem to do anything because a Default Error Dialog Window is opened by C#. I set AllowDBNull to True and now I get an exception returned by the Oracle DB. Do I perhaps need an Event Handler and if so how do I assign it for the partial class ? Also how do I trap the exception and return control back to the windows form, do I use e.Row.RejectChanges(); ?
Help would me much appreciated.