Changing a ReadOnly ChildKeyConstraint?

  • Thread starter Thread starter michael
  • Start date Start date
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
 
I am not sure I am following? All the ChildKeyConstraint does is return the ForeignKeyConstraint in a relation. The value itself is not ReadOnly, so you can set the properties of the
returned ForeignKeyConstraint.


Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Email : (e-mail address removed) <Remove word online. from address>

This posting is provided “AS IS”, with no warranties, and confers no rights.

Get Secure!
http://www.microsoft.com/security
http://www.microsoft.com/protect


--------------------
 
This is out of the help files:

[Visual Basic]
Public Overridable ReadOnly Property ChildKeyConstraint
As ForeignKeyConstraint

Note how the property is ReadOnly. I guess that since I
can change ForeignKeyConstraint.DeleteRule, the ReadOnly
is limited to the ability to change ChildKeyConstraint as
a whole but does not apply to modifying the elements of
ChildKeyConstraint.

Michael

-----Original Message-----
I am not sure I am following? All the ChildKeyConstraint
does is return the ForeignKeyConstraint in a relation.
The value itself is not ReadOnly, so you can set the
properties of the
 
Back
Top