Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (23.5 KB, 3 trang )
Creating a ForeignKeyConstraint Object
The ForeignKeyConstraint constructor is overloaded as follows:
ForeignKeyConstraint(DataColumn parentDataColumn, DataColumn childDataColumn)
ForeignKeyConstraint(DataColumn[] parentDataColumns,
DataColumn[] childDataColumns)
ForeignKeyConstraint(string constraintName, DataColumn parentDataColumn,
DataColumn childDataColumn)
ForeignKeyConstraint(string constraintName,
DataColumn[] parentDataColumns, DataColumn[] childDataColumns)
ForeignKeyConstraint(string constraintName, string parentDataTableName,
string[] parentDataColumnNames, string[] childDataColumnNames,
AcceptRejectRule acceptRejectRule, Rule deleteRule, Rule updateRule)
where
• parentDataColumn and parentDataColumns are the DataColumn objects in the
parent DataTable.
• childDataColumn and childDataColumns are the DataColumn objects in the
child DataTable.
• constraintName is the name you want to assign to the ConstraintName property of
your ForeignKeyConstraint.
• parentDataTableName is the name of the parent DataTable.
• parentDataColumnNames and childDataColumnNames contain the names of the
DataColumn objects in the parent and child DataTable objects.
• acceptRejectRule, deleteRule, and updateRule are the various rules for the
ForeignKey-Constraint.
Earlier in the section "Creating a UniqueConstraint Object
," you saw a code example that
created two DataTable objects named customersDT and ordersDT. The following
example creates a ForeignKeyConstraint object on the CustomerID DataColumn of
ordersDT to the CustomerID DataColumn of customersDT:
ForeignKeyConstraint myFKC =