ForeignKeyConstraint.AcceptRejectRule 属性

指示调用 AcceptChanges 时,通过该约束应发生的操作。

**命名空间:**System.Data
**程序集:**System.Data(在 system.data.dll 中)

语法

声明
Public Overridable Property AcceptRejectRule As AcceptRejectRule
用法
Dim instance As ForeignKeyConstraint
Dim value As AcceptRejectRule

value = instance.AcceptRejectRule

instance.AcceptRejectRule = value
public virtual AcceptRejectRule AcceptRejectRule { get; set; }
public:
virtual property AcceptRejectRule AcceptRejectRule {
    AcceptRejectRule get ();
    void set (AcceptRejectRule value);
}
/** @property */
public AcceptRejectRule get_AcceptRejectRule ()

/** @property */
public void set_AcceptRejectRule (AcceptRejectRule value)
public function get AcceptRejectRule () : AcceptRejectRule

public function set AcceptRejectRule (value : AcceptRejectRule)

属性值

AcceptRejectRule 值之一。可能的值包括 NoneCascade。默认为 None

备注

直到调用了 AcceptChanges 方法后,对 DataRowDataTable 的更改才是最终的。此时,AcceptRejectRule 决定了对任何已更改或删除的值采取的操作过程。

示例

下面的示例创建了 ForeignKeyConstraint,设置其 AcceptRejectRule 以及将约束添加到 DataTable 对象的 ConstraintCollection

' The next line goes into the Declarations section of the module:
' SuppliersProducts is a class derived from DataSet.
Private suppliersProducts As SuppliersProducts 

Private Sub CreateConstraint()
   ' Declare parent column and child column variables.
   Dim parentColumn As DataColumn
   Dim childColumn As DataColumn
   Dim fkConstraint As ForeignKeyConstraint

   ' Set parent and child column variables.
   parentColumn = suppliersProducts.Tables("Suppliers").Columns("SupplierID")
   childColumn = suppliersProducts.Tables("Products").Columns("SupplieriD")
   fkConstraint = New ForeignKeyConstraint( _
       "SuppierFKConstraint", parentColumn, childColumn)

   ' Set null values when a value is deleted.
   fkConstraint.DeleteRule = Rule.SetNull
   fkConstraint.UpdateRule = Rule.Cascade
   fkConstraint.AcceptRejectRule = AcceptRejectRule.Cascade

   ' Add the constraint, and set EnforceConstraints to true.
   suppliersProducts.Tables("Suppliers").Constraints.Add(fkConstraint)
   suppliersProducts.EnforceConstraints = True
End Sub

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

ForeignKeyConstraint 类
ForeignKeyConstraint 成员
System.Data 命名空间
AcceptRejectRule 枚举