asp.net.ph

DataTable.GetErrors Method

System.Data Namespace   DataTable Class


Returns an array of DataRow objects that contain errors.

[ VB ]
Public Function GetErrors ( ) As DataRow ( )

[ C# ]
public DataRow [ ] GetErrors ( );

[ C++ ]
public: DataRow* GetErrors ( ) [ ];

[ JScript ]
public function GetErrors ( ) : DataRow [ ];

Return Value

An array of DataRow objects that have errors.

Remarks

Invoke GetErrors after invoking the DataSet class's GetChanges method. Also, be sure you do not invoke the AcceptChanges on the DataTable until after all errors have been succesfully resolved, and the DataSet re-submitted for updating.

Example

The following example uses the GetErrors method to return an array of DataRow objects that have errors.

Private void PrintAllErrs ( DataSet myDataSet ) {
   DataRow [ ] rowsInError;

   foreach ( DataTable myTable in myDataSet.Tables ) {
      // test if the table has errors. If not, skip it.
      if ( myTable.HasErrors ) {
         // get an array of all rows with errors.
         rowsInError = myTable.GetErrors ( );
         // print the error of each column in each row.
        for ( int i = 0; i < rowsInError.Length; i++ ) {
            foreach ( DataColumn myCol in myTable.Columns ) {
               Response.Write ( myCol.ColumnName + " " +
               rowsInError [ ].GetColumnError ( myCol ) );
           }
         // clear the row errors
         rowsInError [ ].ClearErrors ( );
        }
     }
   }
}
  C# VB

See Also

DataTable Members   AcceptChanges   HasErrors   RowError   SetColumnError 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