System.Data Namespace DataRow Class
Clears the errors for the row, including the RowError and errors set with SetColumnError.
[ VB ]
Public Sub ClearErrors ( )
[ C# ]
void ClearErrors ( );
[ C++ ]
public: void ClearErrors ( );
[ JScript ]
public function ClearErrors ( );
Use SetColumnError and GetColumnError to set and return errors for individual columns.
Set the RowError property to set an error that applies to the whole row.
To determine if any errors exist for the columns collection, use the HasErrors method. Consequently, you can use the GetColumnsInError method to retrieve all of the columns with errors.
The following example first uses the HasErrors property to check for errors. If the row has errors, the GetColumnsInError method returns the array of columns with errors which can then be resolved. The ClearErrors method is then called to clear all errors.
private void GetAllErrs ( DataRow myRow ) {
// check if the row has errors
if ( myRow.HasErrors ) {
// get the array of columns in error.
DataColumn [ ] colArr = myRow.GetColumnsInError ( );
for ( int i = 0; i < colArr.Length; i++ ) {
// insert code to fix errors on each column.
Response.Write ( colArr [ ].ColumnName );
}
// clear errors after reconciling.
myRow.ClearErrors ( );
}
}
Private Sub GetAllErrs ( ByVal myRow As DataRow )
' check if the row has errors
If myRow.HasErrors Then
' get the array of columns in error.
Dim colArr ( ) As DataColumn = myRow.GetColumnsInError ( )
Dim i As Integer
For i = 0 to Ubound ( colArray )
' insert code to fix errors on each column.
Response.Write ( colArr ( i ).ColumnName )
Next i
' clear errors after reconciling.
myRow.ClearErrors ( )
End If
End Sub |
|
C# |
VB |
DataRow Members ColumnsCollection GetColumnError GetColumnsInError HasErrors SetColumnError RowError