Gets or sets a value indicating whether constraint rules are followed when attempting any update operation.
[Visual Basic] Public Property EnforceConstraints As Boolean [C#] public bool EnforceConstraints {get; set;} [C++] public: __property bool get_EnforceConstraints(); public: __property void set_EnforceConstraints(bool); [JScript] public function get EnforceConstraints() : Boolean; public function set EnforceConstraints(Boolean);
true, if rules are enforced; otherwise, false.
Exception Type | Condition |
---|---|
InvalidConstraintException | A constraint isn't applicable. |
See the Constraints property for more details.
The following example sets the EnforceConstraints property to true if any DataTable in a DataSet has at least one constraint.
[Visual Basic]
Private Sub EnforceIfNeeded() Dim t As DataTable Dim ds As DataSet = New DataSet ' Not shown: code to fill the DataSet. For Each t in ds.Tables If t.Constraints.Count > 0 Then ds.EnforceConstraints = True Next End Sub
DataSet Class | DataSet Members | System.Data Namespace | Constraints | UniqueConstraint | ForeignKeyConstraint | DataTable