This documentation is archived and is not being maintained.

DataRelation.ChildKeyConstraint Property

Gets the ForeignKeyConstraint for the relation.

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

Property Value

A ForeignKeyConstraint.


[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)

   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.


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