AcceptRejectRule Enumeration
Collapse the table of content
Expand the table of content

AcceptRejectRule Enumeration


Determines the action that occurs when the AcceptChanges or RejectChanges method is invoked on a DataTable with a ForeignKeyConstraint.

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

public enum AcceptRejectRule

Member nameDescription

Changes are cascaded across the relationship.


No action occurs (default).

Changes to a DataTable are not final until you call the AcceptChanges method. When either AcceptChanges or RejectChanges is called on a row in the parent table, the AcceptRejectRule value determines whether or not changes are propagated to corresponding rows in the child table.

The following example creates a ForeignKeyConstraint, sets various of its properties, including the AcceptRejectRule, and adds it to a DataTable object's ConstraintCollection.

private void CreateConstraint(DataSet dataSet, 
    string table1, string table2,string column1, string column2)
   // Declare parent column and child column variables.
   DataColumn parentColumn;
   DataColumn childColumn;
   ForeignKeyConstraint foreignKeyConstraint;

   // Set parent and child column variables.
   parentColumn = dataSet.Tables[table1].Columns[column1];
   childColumn = dataSet.Tables[table2].Columns[column2];
   foreignKeyConstraint = new ForeignKeyConstraint
      ("SupplierForeignKeyConstraint",  parentColumn, childColumn);

   // Set null values when a value is deleted.
   foreignKeyConstraint.DeleteRule = Rule.SetNull;
   foreignKeyConstraint.UpdateRule = Rule.Cascade;
   foreignKeyConstraint.AcceptRejectRule = AcceptRejectRule.None;

   // Add the constraint, and set EnforceConstraints to true.
   dataSet.EnforceConstraints = true;

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft