Previous | Index | Next 

[INFO] Fields are restored in a different way if an error occurs with a Data control

The VB.NET ADO Data control and its DAO and RDO variants behave slightly differently from the corresponding VB6 control if a database error occurs when the end user attempts to move to a different record. A typical error is a referential integrity error, such as when the form contains a control bound to a field that is a foreign key to another table and the end user types a value that isn’t found in the foreign table.

In such circumstance, the VB6 control display an error message box with a generic message such as “Operation was canceled” and the OK button. When the end user clicks the OK button, the value of the field (or fields) that caused the error is automatically restored to what it was when the record was read. An important detail: fields that don’t create any conflict aren’t restored. The neat effect is that, after clicking the OK button the end user can re-try the move operation and in most cases the move will be successful because all conflicting fields have been fixed.

In the same circumstances, the VB.NET control display a more detailed error message, for example “You cannot add or change a record because another record is required in table ‘XYZ’ “ followed by the question “Do you want to restore original field values?”. If the end user clicks on the Yes button all the fields are restored from the data source (not just the fields that caused the conflict) and the user can then perform a successful move operation. On the other hand, if the end user clicks on the No button, no field is restored and he or she has to manually fix the conflicting value before moving to another record.

 

Previous | Index | Next