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.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

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

.NET Framework

Supported in: 3.5, 3.0, 2.0

.NET Compact Framework

Supported in: 3.5, 2.0

XNA Framework

Supported in: 3.0, 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft