AcceptRejectRule Enumeration
Determines the action that occurs when the AcceptChanges or RejectChanges method is invoked on a DataTable with a ForeignKeyConstraint.
[Visual Basic] <Serializable> Public Enum AcceptRejectRule [C#] [Serializable] public enum AcceptRejectRule [C++] [Serializable] __value public enum AcceptRejectRule [JScript] public Serializable enum AcceptRejectRule
Remarks
Changes to a DataTable are not final until you call the AcceptChanges method. When either AcceptChanges or RejectChanges is called on a row in the parent table, the AcceptRejectRule value determines whether or not changes are propagated to corresponding rows in the child table.
Members
| Member name | Description |
|---|---|
| Cascade Supported by the .NET Compact Framework. | Changes are cascaded across the relationship. |
| None Supported by the .NET Compact Framework. | No action occurs (default). |
Example
[Visual Basic, C#, C++] The following example creates a ForeignKeyConstraint, sets various of its properties, including the AcceptRejectRule, and adds it to a DataTable object's ConstraintCollection.
[Visual Basic] Private Sub CreateConstraint(myDataSet As DataSet, table1 As String, table2 As String, _ column1 As String, column2 As String) ' Declare parent column and child column variables. Dim parentColumn As DataColumn Dim childColumn As DataColumn Dim myForeignKeyConstraint As ForeignKeyConstraint ' Set parent and child column variables. parentColumn = MyDataSet.Tables(table1).Columns(column1) childColumn = MyDataSet.Tables(table2).Columns(column2) myForeignKeyConstraint = New ForeignKeyConstraint _ ("SupplierForeignKeyConstraint", parentColumn, childColumn) ' Set null values when a value is deleted. myForeignKeyConstraint.DeleteRule = Rule.SetNull myForeignKeyConstraint.UpdateRule = Rule.Cascade myForeignKeyConstraint.AcceptRejectRule = AcceptRejectRule.Cascade ' Add the constraint, and set EnforceConstraints to true. myDataSet.Tables(table1).Constraints.Add(myForeignKeyConstraint) myDataSet.EnforceConstraints = True End Sub [C#] private void CreateConstraint(DataSet myDataSet, string table1, string table2, string column1, string column2){ // Declare parent column and child column variables. DataColumn parentColumn; DataColumn childColumn; ForeignKeyConstraint myForeignKeyConstraint; // Set parent and child column variables. parentColumn = myDataSet.Tables[table1].Columns[column1]; childColumn = myDataSet.Tables[table2].Columns[column2]; myForeignKeyConstraint = new ForeignKeyConstraint ("SupplierForeignKeyConstraint", parentColumn, childColumn); // Set null values when a value is deleted. myForeignKeyConstraint.DeleteRule = Rule.SetNull; myForeignKeyConstraint.UpdateRule = Rule.Cascade; myForeignKeyConstraint.AcceptRejectRule = AcceptRejectRule.Cascade; // Add the constraint, and set EnforceConstraints to true. myDataSet.Tables[table1].Constraints.Add(myForeignKeyConstraint); myDataSet.EnforceConstraints = true; } [C++] private: void CreateConstraint(DataSet* myDataSet, String* table1, String* table2, String* column1, String* column2){ // Declare parent column and child column variables. DataColumn* parentColumn; DataColumn* childColumn; ForeignKeyConstraint* myForeignKeyConstraint; // Set parent and child column variables. parentColumn = myDataSet->Tables->Item[table1]->Columns->Item[column1]; childColumn = myDataSet->Tables->Item[table2]->Columns->Item[column2]; myForeignKeyConstraint = new ForeignKeyConstraint (S"SupplierForeignKeyConstraint", parentColumn, childColumn); // Set null values when a value is deleted. myForeignKeyConstraint->DeleteRule = Rule::SetNull; myForeignKeyConstraint->UpdateRule = Rule::Cascade; myForeignKeyConstraint->AcceptRejectRule = AcceptRejectRule::Cascade; // Add the constraint, and set EnforceConstraints to true. myDataSet->Tables->Item[table1]->Constraints->Add(myForeignKeyConstraint); myDataSet->EnforceConstraints = true; }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Data
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
Assembly: System.Data (in System.Data.dll)
See Also
System.Data Namespace | DataTable | UniqueConstraint | ForeignKeyConstraint | AcceptRejectRule