System.Data.ConstraintCollection.CanRemove Method

Indicates whether a System.Data.Constraint can be removed.

Syntax

public bool CanRemove (Constraint constraint)

Parameters

constraint
The System.Data.Constraint to be tested for removal from the collection.

Returns

true if the System.Data.Constraint can be removed from collection; otherwise, false.

Remarks

The default behavior whenever a System.Data.DataRelation is added to a System.Data.DataSet, is to add a System.Data.ForeignKeyConstraint to the parent table and a System.Data.UniqueConstraint to the child table. The System.Data.UniqueConstraint is applied to the primary key column of the parent table, and the System.Data.ForeignKeyConstraint is applied to the foreign key column of the child table. Because trying to remove the System.Data.UniqueConstraint before removing the System.Data.ForeignKeyConstraint causes an exception to be thrown, you should always use the ConstraintCollection.CanRemove(Constraint) method before calling Remove, to make sure that the System.Data.UniqueConstraint can be removed.

Requirements

Namespace: System.Data
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0