asp.net.ph

AcceptRejectRule Enumeration

System.Data Namespace


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

Members


Member Name Description
Cascade Changes are cascaded across the relationship.
None No action occurs.

Remarks

Changes to a DataTable are not final until you call the AcceptChanges method. At that time, constraint-related errors can occur because any ForeignKeyConstraint objects associated with a DataTable are activated to allow deletions and edits to occur freely. Prior to that time, ForeignKeyConstraint objects are inactive. When the ForeignKeyConstraint becomes activated, and errors occur, AcceptRejectRule is called to determine the next course of action.

If changes to a DataTable are rejected, using the RejectChanges method, AcceptRejectRule is called to determine how changes to the relationship are rolled back.

Example

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

private void SetConstraint ( DataSet myDataSet, string table1, 
      string table2, string column1, string column2 ) {

   // declare parent column and child column variables.
   DataColumn parentColumn;
   DataColumn childColumn;
   ForeignKeyConstraint myFKeyConst;

   // set parent and child column variables.
   parentColumn = myDataSet.Tables [ Table1 ].Columns [ Column1 ];
   childColumn = myDataSet.Tables [ Table2 ].Columns [ Column2 ];
   myFKeyConst = new ForeignKeyConstraint
      ( "SupplierFKeyConst",  parentColumn, childColumn );

   // set null values when a value is deleted.
   myFKeyConst.DeleteRule = Rule.SetNull;
   myFKeyConst.UpdateRule = Rule.Cascade;
   myFKeyConst.AcceptRejectRule = AcceptRejectRule.Cascade;

   // add the constraint, and set EnforceConstraints to true.
   myDataSet.Tables [ Table1 ].Constraints.Add ( myFKeyConst );
   myDataSet.EnforceConstraints = true;
}
  C# VB

See Also

Constraint   ConstraintCollection   ForeignKeyConstraint   Rule   UniqueConstraint Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph