DataRelation.ChildKeyConstraint Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the ForeignKeyConstraint for the relation.
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
Property Value
A ForeignKeyConstraint
.
Examples
The following example sets the UpdateRule
, DeleteRule
, and AcceptReject
rule for the ForeignKeyConstraint
associated with the DataRelation
.
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
Remarks
If no associated ForeignKeyConstraint exists for this relationship, it will be created automatically, and pointed to by the ChildKeyConstraint
, when the relation is added to the collection of relations.
Applies to
See also
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om