asp.net.ph

RowNotInTableException Class

System.Data Namespace


Represents the exception that is thrown when trying to perform an operation on a DataRow that is not in a DataTable.

RowNotInTableException Class Members

Collapse   Constructors

Visibility Constructor Parameters
public RowNotInTableException ( )
public RowNotInTableException ( String s )
public RowNotInTableException ( String message , Exception innerException )

Remarks

The RowNotInTableException is thrown when invoking the following methods on a row that has been deleted with either the Delete or the DataRowCollection.Remove method.


Example

The following example initializes a DataTable with one DataColumn and 10 DataRow objects. After deleting a row, the AcceptChanges method is called causing the RowNotInTableException to be thrown.

private void RowNotInTableExceptionDemo ( ) {

   // create a DataTable with one column and ten rows.
   DataTable myTable = new DataTable ( "myTable" );
   DataColumn myColumn = new DataColumn ( "col1" );
   myTable.Columns.Add ( myColumn );
   DataRow newRow;
   for ( int i = 0;i <10; i++ ) {
   newRow = myTable.NewRow ( );
   newRow [ "col1" ] = i;
   myTable.Rows.Add ( newRow );
  }
   try {


   // remove a row and invoke AcceptChanges.
      DataRow removedRow = myTable.Rows [ 9 ];
      removedRow.Delete ( );
      removedRow.AcceptChanges ( );
  }
   catch ( System.Data.RowNotInTableException rowException ) {
      Response.Write ( "RowNotInTableException" );
      Response.Write ( rowException.Message );
   }
}
  C# VB

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