Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

VersionNotFoundException Class

Represents the exception that is thrown when attempting to return a version of a DataRow that has been deleted.

For a list of all members of this type, see VersionNotFoundException Members.

System.Object
   System.Exception
      System.SystemException
         System.Data.DataException
            System.Data.VersionNotFoundException

[Visual Basic]
<Serializable>
Public Class VersionNotFoundException
   Inherits DataException
[C#]
[Serializable]
public class VersionNotFoundException : DataException
[C++]
[Serializable]
public __gc class VersionNotFoundException : public DataException
[JScript]
public
   Serializable
class VersionNotFoundException extends DataException

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Example

[Visual Basic, C#, C++] The following example creates a DataTable with one DataColumn and ten DataRow objects. After deleting a DataRow, attempting to return the removed row's current version results in a VersionNotFoundException exception being thrown.

[Visual Basic] 
Private Sub DemonstrateVersionNotFoundException()
    ' 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
        Console.WriteLine("trying")
        Dim removedRow As DataRow = myTable.Rows(9)
        removedRow.Delete()
        removedRow.AcceptChanges()
        ' Try to get the Current row version.
        Console.WriteLine(removedRow(0, DataRowVersion.Current))
    
    Catch e As System.Data.VersionNotFoundException
        Console.WriteLine("Current version of row not found.")
    End Try
End Sub 'DemonstrateVersionNotFoundException

[C#] 
private void DemonstrateVersionNotFoundException(){
    // 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{
       Console.WriteLine("trying");
       DataRow removedRow = myTable.Rows[9];
       removedRow.Delete();
       removedRow.AcceptChanges();
       // Try to get the Current row version.
       Console.WriteLine(removedRow[0,DataRowVersion.Current]);
 
    }
    catch(System.Data.VersionNotFoundException){
       Console.WriteLine("Current version of row not found.");
    }
 }

[C++] 
private:
void DemonstrateVersionNotFoundException(){
    // Create a DataTable with one column.
    DataTable* myTable = new DataTable(S"myTable");
    DataColumn* myColumn = new DataColumn(S"col1");
    myTable->Columns->Add(myColumn);
    DataRow* newRow;
      
    for(int i = 0;i <10;i++){
       newRow = myTable->NewRow();
       newRow->Item[S"col1"] = __box(i);
       myTable->Rows->Add(newRow);
    }
    myTable->AcceptChanges();
    try{
       Console::WriteLine(S"trying");
       DataRow* removedRow = myTable->Rows->Item[9];
       removedRow->Delete();
       removedRow->AcceptChanges();
       // Try to get the Current row version.
       Console::WriteLine(removedRow->get_Item(0,DataRowVersion::Current));
 
    }
    catch(System::Data::VersionNotFoundException*){
       Console::WriteLine(S"Current version of row not found.");
    }
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Data

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: System.Data (in System.Data.dll)

See Also

VersionNotFoundException Members | System.Data Namespace

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.