Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DataRow.RowError Property

Gets or sets the custom error description for a row.

Namespace:  System.Data
Assembly:  System.Data (in System.Data.dll)
'Declaration
Public Property RowError As String

Property Value

Type: System.String
The text describing an error.

Uses the HasErrors property to first determine whether a DataRow contains errors.

The following example sets error text for ten rows of a table displayed in a DataGrid control.

Private Sub SetRowErrors(ByVal table As DataTable)
    ' Set error text for ten rows.  
    Dim i As Integer 
    For i = 0 to 10
        ' Insert column 1 value into each error.
        table.Rows(i).RowError = "ERROR: " & _
            table.Rows(i)(1).ToString()
    Next 
    ' Get the DataSet for the table, and test it for errors. 
    Dim dataSet As DataSet = table.DataSet
    TestForErrors(dataSet)
End Sub 

Private Sub TestForErrors(ByVal dataSet As DataSet)
    ' Test for errors. If DataSet has errors,  
    ' test each table. 
    If dataSet.HasErrors
        Dim tempDataTable As DataTable
        For Each tempDataTable in dataSet.Tables
            ' If the table has errors, then print them. 
            If(tempDataTable.HasErrors) Then 
                PrintRowErrs(tempDataTable)
            End If 
        Next 
        ' Refresh the DataGrid to see the error-marked rows.
        DataGrid1.Refresh()
    End If 
End Sub 

Private Sub PrintRowErrs(ByVal table As DataTable)
    Dim row As DataRow
    For Each row in table.Rows
       If(row.HasErrors) Then
          Console.WriteLine(row.RowError)
       End If 
    Next 
End Sub

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.