This documentation is archived and is not being maintained.

ForeignKeyConstraint.AcceptRejectRule Property

Indicates the action that should take place across this constraint when AcceptChanges is invoked.

[Visual Basic]
Public Overridable Property AcceptRejectRule As AcceptRejectRule
[C#]
public virtual AcceptRejectRule AcceptRejectRule {get; set;}
[C++]
public: __property virtual AcceptRejectRule get_AcceptRejectRule();
public: __property virtual void set_AcceptRejectRule(AcceptRejectRule);
[JScript]
public function get AcceptRejectRule() : AcceptRejectRule;
public function set AcceptRejectRule(AcceptRejectRule);

Property Value

One of the AcceptRejectRule values. Possible values include None, and Cascade. The default is None.

Remarks

Changes to a DataRow or DataTable are not final until the AcceptChanges method is invoked. At that point, the AcceptRejectRule determines the course of action on any values that have been changed or deleted.

Example

[Visual Basic] The following example creates a ForeignKeyConstraint, sets its AcceptRejectRule, and adds the constraint to a DataTable object's ConstraintCollection.

[Visual Basic] 
' The next line goes into the Declarations section of the module:
' SuppliersProducts is a class derived from DataSet.
Private myDataSet As SuppliersProducts 

Private Sub CreateConstraint()
   ' Declare parent column and child column variables.
   Dim pCol As DataColumn
   Dim cCol As DataColumn
   Dim myFKC As ForeignKeyConstraint
   ' Set parent and child column variables.
   pCol = myDataSet.Tables("Suppliers").Columns("SupplierID")
   cCol = myDataSet.Tables("Products").Columns("SupplieriD")
   myFKC = New ForeignKeyConstraint("SuppierFKConstraint", pCol, cCol)
   ' Set null values when a value is deleted.
   myFKC.DeleteRule = Rule.SetNull
   myFKC.UpdateRule = Rule.Cascade
   myFKC.AcceptRejectRule = AcceptRejectRule.Cascade
   ' Add the constraint, and set EnforceConstraints to true.
   myDataSet.Tables("Suppliers").Constraints.Add(myFKC)
   myDataSet.EnforceConstraints = True
End Sub

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

ForeignKeyConstraint Class | ForeignKeyConstraint Members | System.Data Namespace | AcceptRejectRule

Show: