DataTable.RejectChanges Metodo

Definizione

Esegue il rollback di tutte le modifiche apportate alla tabella dopo il caricamento o dell'ultima chiamata AcceptChanges() .

public:
 void RejectChanges();
public void RejectChanges();
member this.RejectChanges : unit -> unit
Public Sub RejectChanges ()

Esempio

Nell'esempio seguente vengono apportate diverse modifiche a un DataTableoggetto , ma le modifiche vengono rifiutate richiamando il RejectChanges metodo .

private void ShowRejectChanges(DataTable table)
{
    // Print the values of row 1, in the column named "CompanyName."
    Console.WriteLine(table.Rows[1]["CompanyName"]);

    // Make Changes to the column named "CompanyName."
    table.Rows[1]["CompanyName"] = "Taro";

    // Reject the changes.
    table.RejectChanges();

    // Print the original values:
    Console.WriteLine(table.Rows[1]["CompanyName"]);
}
Private Sub ShowRejectChanges(table As DataTable)
    ' Print the values of row 1, in the column named "CompanyName."
    Console.WriteLine(table.Rows(1)("CompanyName"))

    ' Make Changes to the column named "CompanyName."
    table.Rows(1)("CompanyName") = "Taro"

    ' Reject the changes.
    table.RejectChanges()

    ' Print the original values:
    Console.WriteLine(table.Rows(1)("CompanyName"))
End Sub

Commenti

Quando RejectChanges viene chiamato, tutti gli DataRow oggetti ancora in modalità di modifica annullano le modifiche. Le nuove righe vengono rimosse. Righe con l'oggetto DataRowState impostato su Modified o Deleted tornare allo stato originale.

Si applica a

Vedi anche