ForeignKeyConstraint.DeleteRule Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bir satır silindiğinde bu kısıtlamada gerçekleşen eylemi alır veya ayarlar.
public:
virtual property System::Data::Rule DeleteRule { System::Data::Rule get(); void set(System::Data::Rule value); };
public virtual System.Data.Rule DeleteRule { get; set; }
[System.Data.DataSysDescription("ForeignKeyConstraintDeleteRuleDescr")]
public virtual System.Data.Rule DeleteRule { get; set; }
member this.DeleteRule : System.Data.Rule with get, set
[<System.Data.DataSysDescription("ForeignKeyConstraintDeleteRuleDescr")>]
member this.DeleteRule : System.Data.Rule with get, set
Public Overridable Property DeleteRule As Rule
Özellik Değeri
Değerlerden Rule biri. Varsayılan değer: Cascade.
- Öznitelikler
Örnekler
Aşağıdaki örnek bir ForeignKeyConstraint oluşturur, çeşitli özelliklerini ayarlar ve bir DataTable nesnenin ConstraintCollectionöğesine ekler.
' 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
Açıklamalar
Üst tablodan bir satır silindiğinde, DeleteRule alt tablonun (veya tabloların) sütunlarında ne olacağını belirler. Kural olarak ayarlanırsa Cascadealt satırlar silinir.
olarak SetNullayarlanırsa, etkilenen satırların uygun sütunlarına bir DBNull yerleştirilir. Veri kaynağınıza bağlı olarak, bir sütunda null değere izin verilip verilmeyebilir. Örneğin SQL Server, benzersiz olmasalar bile birincil anahtar sütununda birden çok null değerin bulunmasına izin verir. Bununla birlikte, bir DataTableDataColumn nesnenin Unique özelliği olarak trueayarlanırsa, birincil anahtar sütunlarında birden çok null değere izin verilmez.
olarak ayarlanırsa SetDefault, sütunun varsayılan değeri atanır.