M
michael
The following code is directly out of the help files. The
purpose of the snippet is to set the parameters of a
ChildKeyConstraint object. A reference to the ReadOnly
ChildKeyConstraint is returned from the DataRelation.
What happens next I just don't get. If that which is
returned from the DataRelation's ChildKeyConstraint is
ReadOnly, how can another reference to it change its
values?
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
purpose of the snippet is to set the parameters of a
ChildKeyConstraint object. A reference to the ReadOnly
ChildKeyConstraint is returned from the DataRelation.
What happens next I just don't get. If that which is
returned from the DataRelation's ChildKeyConstraint is
ReadOnly, how can another reference to it change its
values?
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