O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handle DataAdapter Concurrency Errors

Problem

You are performing an update that might fail because of a concurrency error.

Solution

Handle the DataAdapter.RowUpdated event and check for errors, or set the DataAdapter.ContinueUpdateOnError property to True.

Discussion

If the DataAdapter executes an update command and detects that the number of affected rows is 0, it throws a DBConcurrencyException. The entire update operation will be aborted, and no further rows in the DataSet will be examined.

Usually, a DBConcurrencyException occurs for one of two reasons:

  • You have incorrectly written the SQL for a custom UPDATE, INSERT, or DELETE command.

  • The row can’t be found because the information being used to find it doesn’t match the current values. This problem ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required