ComponentOne DataObjects for .NET
Error Event (C1DataSet)

C1.Data.2 Assembly > C1.Data Namespace > C1DataSet Class : Error Event
Fired when an error occurs.
Syntax
'Declaration
 
Public Event Error As DataSetEventHandler
public event DataSetEventHandler Error
Event Data

The event handler receives an argument of type DataSetEventArgs containing data related to this event. The following DataSetEventArgs properties provide information specific to this event.

PropertyDescription
The data set where the event has occurred.  
For an unsuccessful operation, information detailing the error.  
Success or failure status of the operation. In events occurring before operation and allowing to change the status argument, user code can change the status to indicate whether to proceed with the operation, skip or abort it.  
Returns the table collection of the data set. Use this property to gain access to table data in 3-tier configuration, where the DataSet argument is not set because it resides on the client and the event is fired on the server.  
Returns the table view collection of the data set. Use this property to gain access to table view data in 3-tier configuration, where the DataSet argument is not set because it resides on the client and the event is fired on the server.  
Remarks
This event gives developers full control over error (exception) handling. It allows to customize/localize error messages or provide a fully customized error handling if necessary.

When this event is fired, the Status argument is set either to ErrorsOccured or to Continue. It is set to ErrorsOccured if the error occurred during an action executed from code, and to Continue if it occurred performing an action requested by data bound controls.

What happens next, whether the error is considered handled or throws an exception, depends on the value you assign to the Status argument:

1. If you set Status to ErrorsOccured, an exception is thrown. To specify the exception information, set the Error argument. Use this option in cases where you do not need to override the standard exception handling.

2. If you set Status to Skip, the error is considered handled and operation resumes as if the error has not occurred (but subsequent actions may not be executed when they depend on the successful completion of the current action). Use this option when you want to handle the error in your code, suppress the standard error handling and consider the operation successful.

3. If you set Status to Continue, C1DataObjects shows a standard error message box and resumes operation without throwing an exception (as in the Skip case). Use this option when you are satisfied with the standard C1DataObjects error message and want to consider the operation successful.

4. It is also possible that you need to show a custom error message or otherwise handle the error in the Error event, then throw an exception, but do not want data bound controls to show their own error messages because you have already shown an error message. To accomplish that, set Status to ErrorsOccured and throw an exception derived from C1DataException with ShowMessage property set to False. Note that this behavior is only supported by data bound controls honoring the ShowMessage property, such as ComponentOne FlexGrid and C1TrueDBGrid.

See Also