System.Data Namespace DataRow Class
Returns an array of columns that have errors.
[ VB ]
Public Function GetColumnsInError ( ) As DataColumn ( )
[ C# ]
public DataColumn [ ] GetColumnsInError ( );
[ C++ ]
public: DataColumn* GetColumnsInError ( ) [ ];
[ JScript ]
public function GetColumnsInError ( ) : DataColumn [ ];
An array of DataColumn objects that contain errors.
The GetColumnsInError allows you to reduce the number of DataColumn objects that must be processed for errors by returning only those columns that have an error. Errors can be set to individual columns with the SetColumnError method. To further reduce the number of processing, check the DataRow class's HasErrors property to first determine if a DataRow has errors before invoking GetColumnsInError.
Use the ClearErrors method to clear all errors on the row, including the RowError.
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 ClearErrors GetColumnError GetErrors HasErrors RowError SetColumnError