What happens when I change the RowUpdatedEventArgs?

  • Thread starter Thread starter Matt Young
  • Start date Start date
M

Matt Young

What I want to do is catch and dismiss expected errors during an update
(resolve the problem and allow the update to continue) but have unexpected
errors throw their exception normally (stopping the update). To accomplish
this, I created a method and attached it to the SqlDataAdapter.RowUpdated
event. It looks similar to this,

private void errorHandler(object sender, SqlRowUpdatedEventArgs args)
{
if(args.Status != UpdateStatus.ErrorsOccurred)
{
return;
}

// determine if the error should be ignored

if(ignoreError)
{
// error should be ignored
args.Status = UpdateStatus.Continue;
args.Errors = null;
}
}

With this code in place, errors I've ignored still throw an exception and
halt the update. This behavior leads me to the conclusion that changing
properties on the SqlRowUpdatedEventArgs object in my method have no lasting
effect. Should this be so?

Can someone please tell me if I have a logical or conceptual flaw here?

Thanks!
Matt

P.S. This is running on the CompactFramework
 
Hi Matt,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to continue processing the
rest rows when and exception is thrown during update. If there is any
misunderstanding, please feel free to let me know.

I have tried it on my computer, however, this was not reproed. The
exception was not thrown after errorHandler is called. You can also try to
use SkipCurrentRow to ignore error.

args.Status = UpdateStatus.SkipCurrentRow;

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Thanks Kevin!

It turns out that the exception was being caused by our code, our real
'errorHandler' was returning without changing the
RowUpdatedEventArgs.Status.

Can you put in a request to improve the MSDN documentation for
RowUpdatedEventArgs? Specifically what the expected outcomes should be for
each of the UpdateStatus enumeration members? Thanks again!

Matt
 
Hi Matt,

If you have any good suggestions for our products, you can send email
directly to (e-mail address removed). You suggestions will be highly
appreciated. Also I will send your request to the appropriate team. Thank
you!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top