Partilhar via


How to: Locate Rows that Have Errors

When working with individual columns and rows of data, there may be times when a record contains an error. You can Check the HasErrors property to determine if errors exist in a DataSet, DataTable, or DataRow.

To locate a row that has errors

  1. Check the HasErrors property to see if there are any errors in the dataset.

  2. If the HasErrors property is true, iterate through the collections of tables, then the rows to find the row with the error.

    Private Sub FindErrors()
        Dim table As Data.DataTable
        Dim row As Data.DataRow
    
        If DataSet1.HasErrors Then 
    
            For Each table In DataSet1.Tables
                If table.HasErrors Then 
    
                    For Each row In table.Rows
                        If row.HasErrors Then 
    
                            ' Process error here. 
                        End If 
                    Next 
                End If 
            Next 
        End If 
    End Sub
    
    private void FindErrors() 
    {
        if (dataSet1.HasErrors)
        {
            foreach (DataTable table in dataSet1.Tables)
            {
                if (table.HasErrors)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        if (row.HasErrors)
                        {
                            // Process error here.
                        }
                    }
                }
            }
        }
    }
    

See Also

Concepts

Preparing Your Application to Receive Data

Fetching Data into Your Application

Binding Controls to Data in Visual Studio

Editing Data in Your Application

Validating Data

Saving Data

Other Resources

Overview of Data Applications in Visual Studio

Connecting to Data in Visual Studio

Tools for Working with Data Sources in Visual Studio