N
Nico
If I throw an exception from the RowChanged event, the exception is handled
/ ignored by ADO and I cannot catch it myself an do something useful with it
Is this intentional and is it right ?
The other events (RowChanging, ColumnChanging, ColumnChanged, I haven't
checked the two delete events) don't do this.
Here's some code which illustrates it.
public static void Main()
{
//create datatable
DataTable tab = new DataTable("Tab1");
tab.Columns.Add("Col1", typeof(string));
tab.Columns.Add("Col2", typeof(string));
//register event
tab.RowChanged += new DataRowChangeEventHandler(OnChange);
//new row
object[] values = new object[] {"FirstRow", "SomeValue"};
try
{
tab.Rows.Add(values);
}
catch (Exception e)
{
//this code is never executed
System.Diagnostics.Debug.WriteLine(e.Message);
throw e;
}
}
public static void OnChange(object o, DataRowChangeEventArgs e)
{
if (e.Row[0].ToString() != "Account") //business rule of some sort
{
throw new Exception("Business rule exception."); //this exception is
caught and handled / ignored by ADO.
}
}
/ ignored by ADO and I cannot catch it myself an do something useful with it
Is this intentional and is it right ?
The other events (RowChanging, ColumnChanging, ColumnChanged, I haven't
checked the two delete events) don't do this.
Here's some code which illustrates it.
public static void Main()
{
//create datatable
DataTable tab = new DataTable("Tab1");
tab.Columns.Add("Col1", typeof(string));
tab.Columns.Add("Col2", typeof(string));
//register event
tab.RowChanged += new DataRowChangeEventHandler(OnChange);
//new row
object[] values = new object[] {"FirstRow", "SomeValue"};
try
{
tab.Rows.Add(values);
}
catch (Exception e)
{
//this code is never executed
System.Diagnostics.Debug.WriteLine(e.Message);
throw e;
}
}
public static void OnChange(object o, DataRowChangeEventArgs e)
{
if (e.Row[0].ToString() != "Account") //business rule of some sort
{
throw new Exception("Business rule exception."); //this exception is
caught and handled / ignored by ADO.
}
}