private void VersionNotFoundExceptionDemo ( ) {
// create a DataTable with one column.
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 );
}
myTable.AcceptChanges ( );
try {
Response.Write ( "trying" );
DataRow removedRow = myTable.Rows [ 9 ];
removedRow.Delete ( );
removedRow.AcceptChanges ( );
// try to get the Current row version.
Response.Write ( removedRow [ 0,DataRowVersion.Current ] );
}
catch ( System.Data.VersionNotFoundException rowException ) {
Response.Write ( "VersionNotFoundException" );
Response.Write ( rowException.Message );
}
}
Private Sub VersionNotFoundExceptionDemo ( )
' create a DataTable with one column.
Dim myTable As New DataTable ( "myTable" )
Dim myColumn As New DataColumn ( "col1" )
myTable.Columns.Add ( myColumn )
Dim newRow As DataRow
Dim i As Integer
For i = 0 To 9
newRow = myTable.NewRow ( )
newRow ( "col1" ) = i
myTable.Rows.Add ( newRow )
Next i
myTable.AcceptChanges ( )
Try
Response.Write ( "trying" )
Dim removedRow As DataRow = myTable.Rows ( 9 )
removedRow.Delete ( )
removedRow.AcceptChanges ( )
' try to get the Current row version.
Response.Write ( removedRow ( 0, DataRowVersion.Current ) )
Catch rowException As System.Data.VersionNotFoundException
Response.Write ( "VersionNotFoundException" )
Response.Write ( rowException.Message )
End Try
End Sub 'VersionNotFoundExceptionDemo |