Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataRowVersion Enumeration

Describes the version of a DataRow.

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

public enum DataRowVersion
public enum DataRowVersion
public enum DataRowVersion

 Member nameDescription
Supported by the .NET Compact FrameworkCurrentThe row contains current values. 
Supported by the .NET Compact FrameworkDefaultThe default version of DataRowState. For a DataRowState value of Added, Modified or Deleted, the default version is Current. For a DataRowState value of Detached, the version is Proposed
Supported by the .NET Compact FrameworkOriginalThe row contains its original values. 
Supported by the .NET Compact FrameworkProposedThe row contains a proposed value. 

The DataRowVersion values are used when retrieving the value found in a DataRow using Item or the GetChildRows of the DataRow object.

The DataRowVersion informs you what version of a DataRow exists. Versions change under the following circumstances:

  • After calling the DataRow object's BeginEdit method, if you change the value, the Current and Proposed values become available.

  • After calling the DataRow object's CancelEdit method, the Proposed value is deleted.

  • After calling the DataRow object's EndEdit method, the Proposed value becomes the Current value.

  • After calling the DataRow object's AcceptChanges method, the Original value becomes identical to the Current value.

  • After calling the DataTable object's AcceptChanges method, the Original value becomes identical to the Current value.

  • After calling the DataRow object's RejectChanges, the Proposed value is discarded, and the version becomes Current.

The following example checks the DataRowVersion of a DataRow before invoking the AcceptChanges method.

Private Sub CheckVersionBeforeAccept()
    'Run a function to create a DataTable with one column.
    Dim dataTable As DataTable = MakeTable()

    Dim dataRow As DataRow = dataTable.NewRow()
    dataRow("FirstName") = "Marcy"
    dataTable.Rows.Add(dataRow)

    dataRow.BeginEdit()
    ' Edit data but keep the same value.
    dataRow(0) = "Marcy"
    ' Uncomment the following line to add a new value.
    ' dataRow(0) = "Richard"
    Console.WriteLine(String.Format("FirstName {0", dataRow(0)))

    ' Compare the proposed version with the current.
    If dataRow.HasVersion(DataRowVersion.Proposed) Then
        If dataRow(0, DataRowVersion.Current) Is dataRow(0, DataRowVersion.Proposed) Then
            Console.WriteLine("The original and the proposed are the same.")
            dataRow.CancelEdit()
        Else
            dataRow.AcceptChanges()
            Console.WriteLine("The original and the proposed are different.")
        End If
    End If
End Sub

Private Function MakeTable() As DataTable
    ' Make a simple table with one column.
    Dim dt As New DataTable("dataTable")
    Dim firstName As New DataColumn("FirstName", _
       Type.GetType("System.String"))
    dt.Columns.Add(firstName)
    Return dt
End Function

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft