Catch Exceptions Raised in Custom Stored Procedures and Triggers

Updated March 17, 2006
Iron Speed Designer V4.0 and later

Exceptions and error messages sent from custom triggers in your database, database-enforced constraints and stored procedures are transmitted to the user interface layer of your application and relayed to the user.  In some cases, these database-generated error messages may be too technical or jargonistic for your application users to understand.  For example, an error message saying, “ORA-00xxx: ... constraint violated ...” isn’t informative or helpful for most users.

You can catch exceptions thrown by your database and replace the associated error messages with your own, more helpful messages.  Several mechanisms are described below.

Override OnSaveData in the RecordControl class

If you want to catch exceptions reported by your database, you can override the OnSaveData function in the RecordControl class in the page’s customizable class file.  Place a Try/Catch block around the commit transaction to handle the exception.  The following pseudo-code might help:



          Call MyBase.OnSaveData

          Call CommitTransaction


          Handle the database exceptions generated by CommitTransaction.

     End Catch

Modify the underlying Base Classes handling of SQL Exceptions

Handle the message directly or to provide a more explanatory version of the error message in the ConvertSQLServerDBException function, located in:


See Also

See the following help from Microsoft on this topic:

HOW TO: Return Errors and Warnings from a SQL Server Stored Procedure in ADO.NET;en-us;321903&Product=adonet