Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ChildKeyConstraint Property

DataRelation.ChildKeyConstraint Property

Gets the ForeignKeyConstraint for the relation.

[Visual Basic]
Public Overridable ReadOnly Property ChildKeyConstraint As _
   ForeignKeyConstraint
[C#]
public virtual ForeignKeyConstraint ChildKeyConstraint {get;}
[C++]
public: __property virtual ForeignKeyConstraint*
   get_ChildKeyConstraint();
[JScript]
public function get ChildKeyConstraint() : ForeignKeyConstraint;

Property Value

A ForeignKeyConstraint.

Example

[Visual Basic] The following example sets the UpdateRule, DeleteRule, and AcceptReject rule for the ForeignKeyConstraint associated with the DataRelation.

[Visual Basic] 
Private Sub SetChildKeyConstraint(ds As DataSet)
   Dim dr As DataRelation
   Dim cCol As DataColumn
   Dim pCol As DataColumn
   ' Set child and parent columns.
   pCol = ds.Tables("Suppliers").Columns("SupplierID")
   cCol = ds.Tables("Products").Columns("SupplierID")
   dr = New DataRelation("SuppliersConstraint", pCol, cCol)

   ds.Relations.Add(dr)
   Dim fk As ForeignKeyConstraint = dr.ChildKeyConstraint
   fk.DeleteRule = Rule.SetNull
   fk.UpdateRule = Rule.Cascade
   fk.AcceptRejectRule = AcceptRejectRule.Cascade
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

DataRelation Class | DataRelation Members | System.Data Namespace | AcceptRejectRule | ParentKeyConstraint | Rule

Show:
© 2015 Microsoft