asp.net.ph

DataSet.HasErrors Property

System.Data Namespace   DataSet Class


Checks whether there are errors in any of the rows in any of the tables of this DataSet.

Syntax


Script DataSet.HasErrors [ = true | false ]

Property Value

This property returns only a boolean value: true if any table has errors; otherwise, false.

The property is read only with no default value.

Remarks

The HasErrors property is usually consulted after creating using the GetChanges method. Check the HasErrors property of the DataSet created with the GetChanges method to determine if any errors exists. If so, you should reconcile the errors before proceeding to update the data source with the changes.

Each DataTable in a DataSet also has a HasErrors property. Use the DataSet object's HasErrors to determine if any table has errors before checking individual DataTable objects. If a DataTable has errors, the GetErrors method returns an array of DataRow objects that have errors.

Example

The following example uses the HasErrors property to determine whether a DataSet object contains errors. If so, the errors for each DataRow in each DataTable are printed.

private void CheckForErrors ( ) {
   if ( !myDataSet.HasErrors ) {
      myDataSet.Merge ( mainDataSet );
  }
   else {
      PrintRowErrs ( myDataSet );
   }
}

private void PrintRowErrs ( DataSet myDataSet ) {
   foreach ( DataTable myTable in myDataSet.Tables ) {

      foreach ( DataRow myRow in myTable.Rows ) {
         if ( myRow.HasErrors ) {
            Response.Write ( myRow.RowError );
        }
     }
   }
}
  C# VB

See Also

DataSet Members   GetChanges   HasChanges Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph