The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,160 other followers

.NET/C#: When the DbDataAdapter.Update throws an exception, it is a bit tough to find the involved Command

Posted by jpluimers on 2013/09/24

When you call a DbDataAdapter.Update, and it throws an exception, the exception does not include the underlying Command and its parameters.

Since the DbDataAdapter can have three commands for applying changes (DeleteCommand, InsertCommand and UpdateCommand), asking those is a bit inconvenient.

The other way is to attach an event handler to the DAL specific RowUpdated event (for instance SqlDataAdapter.RowUpdated).

This is event is called from the virtual OnRowUpdatedMethod, and has a value parameter of type RowUpdatedEventArgs which contains the Command, and Errors that occurred. Errors is just the Exception that can help indicate what went wrong.


via: DbDataAdapter.Update Method System.Data.Common.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: