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.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft