共用方式為


ForeignKeyConstraint.UpdateRule 屬性

定義

取得或設定資料列更新時會跨越這個條件約束發生的動作。

public:
 virtual property System::Data::Rule UpdateRule { System::Data::Rule get(); void set(System::Data::Rule value); };
public virtual System.Data.Rule UpdateRule { get; set; }
[System.Data.DataSysDescription("ForeignKeyConstraintUpdateRuleDescr")]
public virtual System.Data.Rule UpdateRule { get; set; }
member this.UpdateRule : System.Data.Rule with get, set
[<System.Data.DataSysDescription("ForeignKeyConstraintUpdateRuleDescr")>]
member this.UpdateRule : System.Data.Rule with get, set
Public Overridable Property UpdateRule As Rule

屬性值

其中一個 Rule 值。 預設為 Cascade

屬性

範例

下列範例會建立 、 ForeignKeyConstraint設定其各種屬性,並將它新增至 DataTable 物件的 ConstraintCollection

' The next line goes into the Declarations section of the module:
' SuppliersProducts is a class derived from DataSet.
Private suppliersProducts As SuppliersProducts 

Private Sub CreateConstraint()
   ' Declare parent column and child column variables.
   Dim parentColumn As DataColumn
   Dim childColumn As DataColumn
   Dim fkConstraint As ForeignKeyConstraint

   ' Set parent and child column variables.
   parentColumn = suppliersProducts.Tables("Suppliers").Columns("SupplierID")
   childColumn = suppliersProducts.Tables("Products").Columns("SupplieriD")
   fkConstraint = New ForeignKeyConstraint( _
       "SuppierFKConstraint", parentColumn, childColumn)

   ' Set null values when a value is deleted.
   fkConstraint.DeleteRule = Rule.SetNull
   fkConstraint.UpdateRule = Rule.Cascade
   fkConstraint.AcceptRejectRule = AcceptRejectRule.Cascade

   ' Add the constraint, and set EnforceConstraints to true.
   suppliersProducts.Tables("Suppliers").Constraints.Add(fkConstraint)
   suppliersProducts.EnforceConstraints = True
End Sub

適用於

另請參閱