Rule 列挙体
アセンブリ: System.Data (system.data.dll 内)


メンバ名 | 説明 | |
---|---|---|
![]() | Cascade | 関連行を削除または更新します。これは、既定の設定です。 |
![]() | None | 関連行で何もアクションが実行されません。 |
![]() | SetDefault | 関連行の値を DefaultValue プロパティに格納されている値に設定します。 |
![]() | SetNull | 関連行の値を DBNull に設定します。 |

Rule 値は、DataTable オブジェクトの ConstraintCollection 内に存在する、ForeignKeyConstraint オブジェクトの UpdateRule プロパティと DeleteRule プロパティに設定されます。
Rule 値は、列内の値を削除または更新したときに実行されるアクションを決定します。削除と更新のうち、規則を設定するときに重要で注意が必要なのは、削除の方です。
値の削除の場合、Cascade は、その値が格納されている他のすべての行も削除することを指定します。SetNull は、すべての子列内の値が null 値に設定されることを指定します。SetDefault は、すべての子列をその列の既定値に設定することを指定します。None は、何もアクションを実行せず、例外を生成することを指定します。
値の更新の場合、Cascade は、すべての子列も同様に新しい値で更新することを指定します。SetNull は、すべての子列を null 値に設定することを指定します。SetDefault は、すべての子列の値を既定値に設定することを指定します。None は、何もアクションを実行せず、例外を生成することを指定します。
EnforceConstraints プロパティが true の場合を除いては、DataSet に対する制約は適用されません。
AcceptChanges メソッドを呼び出すと、AcceptRejectRule によって実行するアクションも決定されます。

' 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 fkeyConstraint As ForeignKeyConstraint ' Set parent and child column variables. parentColumn = suppliersProducts.Tables("Suppliers").Columns("SupplierID") childColumn = suppliersProducts.Tables("Products").Columns("SupplierID") fkeyConstraint = New ForeignKeyConstraint( _ "SupplierFKConstraint", parentColumn, childColumn) ' Set null values when a value is deleted. fkeyConstraint.DeleteRule = Rule.SetNull fkeyConstraint.UpdateRule = Rule.Cascade fkeyConstraint.AcceptRejectRule = AcceptRejectRule.Cascade ' Add the constraint, and set EnforceConstraints to true. suppliersProducts.Tables("Products").Constraints.Add(fkeyConstraint) 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Rule 列挙体のページへのリンク