System.Data Namespace ConstraintCollection Class
Removes a Constraint from the ConstraintCollection.
1. Removes the specified Constraint from the collection.
2. Removes the constraint, specified by name, from the collection.
The following example removes a Constraint from a ConstraintCollection after testing for its presence with the Contains method, and whether it can be removed with the CanRemove method.
NOTE: This example uses one of the overloaded versions of Remove. For other examples that may be available, see the individual overload topics.
private void RemoveConstraint ( ConstraintCollection myConstraints,
Constraint myConstraint ) {
try {
if ( myConstraints.Contains ( myConstraint.ConstraintName ) ) {
if ( myConstraints.CanRemove ( myConstraint ) ) {
myConstraints.Remove ( myConstraint.ConstraintName );
}
}
}
catch ( Exception myException ) {
Response.Write ( myException.Message );
}
}
Private Sub RemoveConstraint ( myConstraints As ConstraintCollection, _
myConstraint As Constraint )
Try
If myConstraints.Contains ( myConstraint.ConstraintName ) Then
If myConstraints.CanRemove ( myConstraint ) Then
myConstraints.Remove ( myConstraint.ConstraintName )
End If
End If
Catch myException As Exception
Response.Write ( myException.Message )
End Try
End Sub |
|
C# |
VB |
ConstraintCollection Members