private void SetChildKeyConstraint ( DataSet ds ) {
DataColumn cCol, pCol;
// set child and parent columns.
pCol = ds.Tables [ "Suppliers" ].Columns [ "SupplierID" ];
cCol = ds.Tables [ "Products" ].Columns [ "SupplierID" ];
DataRelation dr = new DataRelation ( "SuppliersConstraint", pCol, cCol )
ForeignKeyConstraint fk = dr.ChildKeyConstraint;
fk.DeleteRule = Rule.SetNull;
fk.UpdateRule = Rule.Cascade;
fk.AcceptRejectRule = AcceptRejectRule.Cascade;
}
Private Sub SetChildKeyConstraint ( ds As DataSet )
Dim cCol, pCol As DataColumn
' set child and parent columns.
pCol = ds.Tables ( "Suppliers" ).Columns ( "SupplierID" )
cCol = ds.Tables ( "Products" ).Columns ( "SupplierID" )
Dim dr As 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 |