다음을 통해 공유


ForeignKeyConstraint.DeleteRule 속성

행이 삭제될 때 이 제약 조건에 발생하는 동작을 가져오거나 설정합니다.

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

구문

‘선언
Public Overridable Property DeleteRule As Rule
‘사용 방법
Dim instance As ForeignKeyConstraint
Dim value As Rule

value = instance.DeleteRule

instance.DeleteRule = value
public virtual Rule DeleteRule { get; set; }
public:
virtual property Rule DeleteRule {
    Rule get ();
    void set (Rule value);
}
/** @property */
public Rule get_DeleteRule ()

/** @property */
public void set_DeleteRule (Rule value)
public function get DeleteRule () : Rule

public function set DeleteRule (value : Rule)

속성 값

Rule 값 중 하나입니다. 기본값은 Cascade입니다.

설명

부모 테이블에서 행이 삭제되면 DeleteRule은 자식 테이블의 열에서 수행될 작업을 결정합니다. 규칙이 Cascade로 설정되면 자식 행이 삭제됩니다.

SetNull로 설정하면, 영향을 받는 행의 해당 열에 DBnull이 배치됩니다. 그러나 특정 열에 Null 값을 사용할 수 있는지 여부는 데이터 소스에 따라 달라집니다. 예를 들어, SQLServer의 경우에는 기본 키 열에 고유하지 않은 여러 개의 Null 값을 사용할 수 있지만, DataTable의 경우에는 DataColumn 개체의 Unique 속성이 true로 설정되었으면 기본 키 열에 여러 개의 Null 값을 사용할 수 없습니다.

SetDefault로 설정하면 열에 기본값이 할당됩니다.

예제

다음 예제에서는 ForeignKeyConstraint를 만들고 다양한 속성을 설정한 다음 이것을 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 네임스페이스