共用方式為


DataRelation.ChildKeyConstraint 屬性

定義

取得關聯的 ForeignKeyConstraint

public:
 virtual property System::Data::ForeignKeyConstraint ^ ChildKeyConstraint { System::Data::ForeignKeyConstraint ^ get(); };
public virtual System.Data.ForeignKeyConstraint? ChildKeyConstraint { get; }
public virtual System.Data.ForeignKeyConstraint ChildKeyConstraint { get; }
member this.ChildKeyConstraint : System.Data.ForeignKeyConstraint
Public Overridable ReadOnly Property ChildKeyConstraint As ForeignKeyConstraint

屬性值

ForeignKeyConstraint

範例

下列範例會UpdateRule設定與相關聯 之的DataRelationDeleteRuleAcceptReject 規則ForeignKeyConstraint

Private Sub SetChildKeyConstraint(dataSet As DataSet)
   ' Set child and parent columns.
   Dim parentColumn As DataColumn = dataSet.Tables( _
       "Suppliers").Columns("SupplierID")
   Dim childColumn As DataColumn = dataSet.Tables( _
       "Products").Columns("SupplierID")
   Dim relation As New DataRelation( _
       "SuppliersConstraint", parentColumn, childColumn)
   dataSet.Relations.Add(relation)

   Dim foreignKey As ForeignKeyConstraint = _
       relation.ChildKeyConstraint
   foreignKey.DeleteRule = Rule.SetNull
   foreignKey.UpdateRule = Rule.Cascade
   foreignKey.AcceptRejectRule = AcceptRejectRule.Cascade
End Sub

備註

如果這個關聯性沒有任何關聯的 ForeignKeyConstraint 存在,當關聯性加入至關聯集合時,就會自動建立該關聯性,並由 ChildKeyConstraint指向 。

適用於

另請參閱