DataSet.RejectChanges Método

Definição

Reverte todas as alterações feitas ao DataSet desde que foi criado ou desde a última vez em que o AcceptChanges() foi chamado.Rolls back all the changes made to the DataSet since it was created, or since the last time AcceptChanges() was called.

public:
 virtual void RejectChanges();
public virtual void RejectChanges ();
abstract member RejectChanges : unit -> unit
override this.RejectChanges : unit -> unit
Public Overridable Sub RejectChanges ()

Exemplos

O exemplo a seguir mostra uma classe derivada da DataSet classe.The following example shows a class derived from the DataSet class. O RejectChanges evento é invocado de dentro de uma função.The RejectChanges event is invoked from within a function.

private void RejectChangesInDataSet()
{
    // Instantiate the derived DataSet.
    DerivedDataSet derivedData = new DerivedDataSet();

    // Insert code to change values.

    // Invoke the RejectChanges method in the derived class.
    derivedData.RejectDataSetChanges();
}

public  class DerivedDataSet:System.Data.DataSet
{
    public void RejectDataSetChanges()
    {
        // Invoke the RejectChanges method.
        this.RejectChanges();
    }
}
Private Sub RejectChangesInDataSet()
    ' Instantiate the derived DataSet.
    Dim derivedData As DerivedDataSet
    derivedData = New DerivedDataSet()

   ' Insert code to change values.

   ' Invoke the RejectChanges method in the derived class.
   derivedData.RejectDataSetChanges()
End Sub
   
Public Class DerivedDataSet
    Inherits System.Data.DataSet
     
    Public Sub RejectDataSetChanges()
        ' Invoke the RejectChanges method.
        Me.RejectChanges()
    End Sub
 End Class

Comentários

Invoque o DataSet.RejectChanges para chamar o DataTable.RejectChanges método em todos os DataTable objetos contidos no DataSet .Invoke the DataSet.RejectChanges to call the DataTable.RejectChanges method on all DataTable objects contained by the DataSet.

DataRow os objetos contidos no DataSet podem ser definidos no modo de edição invocando o DataRow.BeginEdit método.DataRow objects contained by the DataSet can each be set into edit mode by invoking the DataRow.BeginEdit method. Depois de invocar o DataRow.EndEdit método, as alterações podem ser rejeitadas chamando o DataTable.RejectChanges no DataTable ao qual os DataRow objetos pertencem.After invoking the DataRow.EndEdit method, changes can be rejected by calling the DataTable.RejectChanges on the DataTable to which the DataRow objects belong.

Quando o DataTable.RejectChanges método é chamado, todas as linhas que ainda estão no modo de edição cancelam suas edições.When the DataTable.RejectChanges method is called, any rows still in edit-mode cancel their edits. Novas linhas são removidas.New rows are removed. Linhas modificadas e excluídas retornam ao estado original ( DataRowState.Unchanged ).Modified and deleted rows return back to their original state (DataRowState.Unchanged).

AcceptChanges e RejectChanges se aplicam somente a DataRow alterações relacionadas (ou seja,,,, Add Remove Delete e Modify ).AcceptChanges and RejectChanges only apply to DataRow related changes (that is, Add, Remove, Delete, and Modify). Eles não são aplicáveis a alterações de esquema ou estruturais.They are not applicable to schema or structural changes.

Aplica-se a