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

Use Last-In-Wins Concurrency with the DataAdapter

Problem

You want to customize the DataAdapter update logic so that changes are allowed, even to records that have been modified by other users.

Solution

Customize the UpdateCommand so that is selects records based on a single unique field, instead of a combination of fields.

Discussion

The automatically generated update logic provided by the CommandBuilder selects records for an update by attempting to match each field in the WHERE clause. Here’s an example update command for the Shippers table from the Northwind database:

UPDATE Shippers SET CompanyName=[NewVal]
  WHERE ShipperID=[LastVal] AND CompanyName=[LastVal] AND Phone=[LastVal] ...

This approach is usually inefficient because it increases the amount ...

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