Export (0) Print
Expand All

ForeignKeyConstraint Constructor (String, String, String, String[], String[], AcceptRejectRule, Rule, Rule)

This constructor is provided for design time support in the Visual Studio environment. ForeignKeyConstraint objects created by using this constructor must then be added to the collection via AddRange. Tables and columns with the specified names must exist at the time the method is called, or if BeginInit has been called prior to calling this constructor, the tables and columns with the specified names must exist at the time that EndInit is called.

Namespace:  System.Data
Assembly:  System.Data (in System.Data.dll)

[BrowsableAttribute(false)]
public ForeignKeyConstraint(
	string constraintName,
	string parentTableName,
	string parentTableNamespace,
	string[] parentColumnNames,
	string[] childColumnNames,
	AcceptRejectRule acceptRejectRule,
	Rule deleteRule,
	Rule updateRule
)

Parameters

constraintName
Type: System.String

The name of the constraint.

parentTableName
Type: System.String

The name of the parent DataTable that contains parent DataColumn objects in the constraint.

parentTableNamespace
Type: System.String

The name of the Namespace.

parentColumnNames
Type: System.String[]

An array of the names of parent DataColumn objects in the constraint.

childColumnNames
Type: System.String[]

An array of the names of child DataColumn objects in the constraint.

acceptRejectRule
Type: System.Data.AcceptRejectRule

One of the AcceptRejectRule values. Possible values include None, Cascade, and Default.

deleteRule
Type: System.Data.Rule

One of the Rule values to use when a row is deleted. The default is Cascade. Possible values include: None, Cascade, SetNull, SetDefault, and Default.

updateRule
Type: System.Data.Rule

One of the Rule values to use when a row is updated. The default is Cascade. Possible values include: None, Cascade, SetNull, SetDefault, and Default.

ExceptionCondition
ArgumentNullException

One or both of the columns is null.

InvalidConstraintException

The columns have different data types.

-Or -

The tables don't belong to the same DataSet.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show:
© 2015 Microsoft