PC Review


Reply
Thread Tools Rate Thread

OnRowChangedEvent catches all Exceptions

 
 
Nico
Guest
Posts: n/a
 
      26th Aug 2003
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.
}
}



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lets hope it catches on here !! Abarbarian General Discussion 10 26th Aug 2009 10:09 PM
Sample program: Try / Catch exceptions user defined exceptions derived from System.Exception raylopez99 Microsoft C# .NET 2 23rd Sep 2007 11:47 AM
Multiple Catches in Try/Catch zacks@construction-imaging.com Microsoft VB .NET 3 16th Jan 2006 07:07 PM
do try/catches cascade? darrel Microsoft ASP .NET 4 10th Aug 2005 04:43 PM
try-catches Tim923 Microsoft C# .NET 9 29th Oct 2004 04:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:47 PM.