Handling Classic ADO.NET Concurrency Errors
At times multiple users of your application may edit the same information in a record and try to save changes. This creates a concurrency problem. There are three main scenarios are:
- Two users grab the same record. The first user updates the record and the second user tries to update the record
- Two users grab the same record. The first user updates the record and the second user tries to delete the record
- Two users grab the same record. The first user deletes the record and the second user tries to update the record
Note: If you are using stored procedures to update data, you need to add a Timestamp column to the associated table so that ADO.NET raises a concurrency exception. The MM .NET Business Layer Generator automatically adds the Timestamp column to the WHERE clause of the UPDATE stored procedure.
When ADO.NET encounters a concurrency conflict, it throws a DBConcurrencyException. The mmBusinessObject class catches this exception in its HandleException method and calls its protected HandleConcurrencyException() method which in turn calls the BuildConcurrencyExceptionMessage method. This method builds a message that lists the current data in the database, and the proposed data which can then be displayed to the user. For example:

This message is automatically displayed for you in MM .NET desktop applications.
To retrieve the current data in the database, the business object's GetConflictData method is called to return a DataRow containing the current values. By default, the business object dynamically builds a SELECT statement using its TableName property as well as the primary key information you have specified in the PrimaryKey or PrimaryKeys fields.
While the automatic generation of this SELECT statement is usually sufficient, you may have cases where you need to manually specify the concurrency SELECT statement, such as when the back end table name is different than the name specified in the business object's TableName property. In this case, you need to specify the proper SELECT statement in the business object's ConcurrencySelectStatement property.
For example, in C#:
this.ConcurrencySelectStatement = "SELECT * FROM " + this.SourceTable + " WHERE OrderID = @OrderID AND ProductID = @ProductID";
And in VB .NET:
Me.ConcurrencySelectStatement = "SELECT * FROM " + Me.SourceTable + " WHERE OrderID = @OrderID AND ProductID = @ProductID"
Changing Default Concurrency Handling Behavior
There are a number of ways you can change the default MM .NET concurrency handling behavior:- Override the business object's HandleConcurrencyException method and perform completely different handling logic
- Override the business object's BuildConcurrencyExceptionMessage method to change how the exception message is built
- Override the business object's ResolveCurrency method to change how the currency exception is resolved
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 07/29/18
Comment or report problem with topic
