NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Rule Enumeration

Indicates the action that occurs when a ForeignKeyConstraint is enforced.

[Visual Basic]
Public Enum Rule
[C#]
public enum Rule
[C++]
public enum Rule

[JScript] In JScript, you can use the enumerations in the NGWS frameworks, but you cannot define your own.

Remarks

The Rule values are set to the UpdateRule and the DeleteRule properties of a ForeignKeyConstraint object found in a DataTable object's ConstraintsCollection.

The Rule values determine the action that occurs when a value in a column is either deleted or updated. Of the two, deleting a value is the more critical and demanding of attention when setting a rule.

In the case where a value is deleted, Cascade specifies that all rows containing that value are also deleted. SetNull specifies that values in all child columns are set to null values. SetDefault specifies that all child columns be set to the default value for the column. None specifies that no action will occur, but exceptions will be thrown.

In the case where a value is updated, Cascade specifies that all child columns are likewise updated with the new value. SetNull specifies that all child columns be set to null values. SetDefault specifies that all child column values be set to the default value. None specifies that no action be taken, but exceptions will be thrown.

Constraints on a DataSet are not enforced unless the EnforceConstraints property is true.

When the AcceptChanges method is called, the AcceptRejectRule further determines what action occurs.

Members

Member Name Description
Cascade Changes are cascaded through the relationship.
Default [reviewers?]
None No action occurs.
SetDefault Default values are set in the rows affected by the deletion.
SetNull Null values are set in the rows affected by the deletion.

Requirements

Namespace: System.Data

Assembly: System.Data.dll

Example [Visual Basic]

[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

See Also

System.Data Namespace