Gets a value indicating whether there are errors in a columns collection.
[Visual Basic] Public ReadOnly Property HasErrors As Boolean [C#] public bool HasErrors {get;} [C++] public: __property bool get_HasErrors(); [JScript] public function get HasErrors() : Boolean;
true if any column in the collection contains an error; otherwise, false.
Use SetColumnError and GetColumnError to set and return errors for individual columns.
The ClearErrors method clears all errors for the columns collection.
The following example uses the HasErrors and ClearError methods to clear all errors of a DataRow object found in a System.WinForms.DataGrid control's DataTable.
[Visual Basic]
Private Sub PrintAllErrs() Dim rowsInError() As DataRow Dim t As DataTable Dim ds As DataSet Dim i As Integer Dim c As DataColumn ds = DataSet1 For Each t in ds.Tables ' Test if the table has errors. If not, skip it. If t.HasErrors Then ' Get an array of all rows with errors. rowsInError = t.GetErrors ' Print the error of each column in each row. For i = 0 To UBound(rowsInError) For Each c In t.Columns Console.WriteLine(c.ColumnName, rowsInError(i).GetColumnError(c)) Next c ' Clear the row errors rowsInError(i).ClearErrors Next i End If Next t End Sub
DataRow Class | DataRow Members | System.Data Namespace | ClearErrors | ColumnsCollection | GetColumnError | GetColumnsInError | SetColumnError