다음을 통해 공유


Rule 열거형

ForeignKeyConstraint가 적용될 때 발생하는 작업을 나타냅니다.

네임스페이스: System.Data
어셈블리: System.Data(system.data.dll)

구문

‘선언
Public Enumeration Rule
‘사용 방법
Dim instance As Rule
public enum Rule
public enum class Rule
public enum Rule
public enum Rule

멤버

  멤버 이름 설명
Supported by the .NET Compact Framework Cascade 관련 행을 삭제하거나 업데이트합니다. 기본값입니다. 
Supported by the .NET Compact Framework None 관련 행에서 수행된 작업이 없습니다. 
Supported by the .NET Compact Framework SetDefault 관련 행의 값을 DefaultValue 속성에 포함된 값으로 설정합니다. 
Supported by the .NET Compact Framework SetNull 관련 행의 값을 DBNull로 설정합니다. 

설명

Rule 값은 DataTable 개체의 ConstraintCollection에 있는 ForeignKeyConstraint 개체의 DeleteRule 속성과 UpdateRule에 설정됩니다.

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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

System.Data 네임스페이스
DataTable.Constraints 속성
ForeignKeyConstraint 클래스