asp.net.ph

ForeignKeyConstraint.UpdateRule Property

ForeignKeyConstraint Class   System.Data Namespace


Sets or retrieves the action that occurs across this constraint on when a row is updated.

[ VB ]
Overridable Public Property UpdateRule As Rule

[ C# ]
public Rule UpdateRule {virtual get; virtual set;}

[ C++ ]
public: __property virtual Rule get_UpdateRule ( );
public: __property virtual void set_UpdateRule ( Rule );

[ JScript ]
public function get UpdateRule ( ) : Rule;
public function set UpdateRule ( Rule );

Property Value

One of the Rule values. The default is Cascade. Possible values include: None, Cascade, SetNull, SetDefault, and Default.

Example

The following example initializes a ForeignKeyConstraint, sets various of its properties, and adds it to a DataTable object's ConstraintsCollection.

[ VB ] 
' the next line goes into the Declarations section of the module:
' suppliersProducts is a class derived from DataSet.
Private myDataSet As SuppliersProducts 
Private Sub CreateConstraint ( )
   ' declare parent column and child column variables.
   Dim pCol As DataColumn
   Dim cCol As DataColumn
   Dim myFKC As ForeignKeyConstraint
   ' set parent and child column variables.
   pCol = myDataSet.Tables ( "Suppliers ).Columns ( "SupplierID" )
   cCol = myDataSet.Tables ( "Products" ).Columns ( "SupplieriD" )
   myFKC = New ForeignKeyConstraint ( "SuppierFKConstraint", pCol, cCol )
   ' set null values when a value is deleted.
   myFKC.DeleteRule = Rule.SetNull
   myFKC.UpdateRule = Rule.Cascade
   myFKC.AcceptRejectRule = AcceptRejectRule.Cascade
   ' add the constraint, and set EnforceConstraints to true.
   myDataSet.Tables ( "Suppliers" ).Constraints.Add myFKC
   myDataSet.EnforceConstraints = True
End Sub
See Also

ForeignKeyConstraint Members   AcceptRejectRule   Rule Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph