Optimize DataAdapter Performance with a Timestamp

Problem

You want to use strict concurrency checking but optimize DataAdapter performance.

Solution

Add a timestamp field to your table, and create a custom update command that uses it.

Discussion

You can use the CommandBuilder to generate update logic for your database tables. However, the autogenerated SQL statements it creates are usually inefficient because they attempt to match every field in a table. As the number of columns increases in the DataTable, the number of columns in the WHERE clause of the query also increases.

To improve on this system, you can add a special timestamp field to your table. Most database systems support some kind of timestamp data type, which the data source updates automatically ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.