System.Data Namespace DataRelation Class
Initializes a new instance of the DataRelation class using the specified DataRelation name, and parent and child DataColumn objects, and a value indicating whether to create constraints.
[ VB ]
Overloads Public Sub New ( _
ByVal relationName As String, _
ByVal parentColumn As DataColumn, _
ByVal childColumn As DataColumn, _
ByVal createConstraints As Boolean _
)
[ C# ]
public DataRelation (
string relationName,
DataColumn parentColumn,
DataColumn childColumn,
bool createConstraints
);
[ C++ ]
public: DataRelation (
String* relationName,
DataColumn* parentColumn,
DataColumn* childColumn,
bool createConstraints
);
[ JScript ]
public function DataRelation (
relationName : String,
parentColumn : DataColumn,
childColumn : DataColumn,
createConstraints : Boolean
);
- relationName
- The name of the relation. If a null reference or an empty string ( "" ), a default name will be given when the created object is added to the DataRelationCollection.
- parentColumn
- The parent DataColumn in the relation.
- childColumn
- The child DataColumn in the relation.
- createConstraints
- A value indicating whether constraints are created. true, if constraints are created, otherwise, false.
The following example initializes a new DataRelation using this constructor, and adds it to the DataRelationCollection of a DataSet.
DataRelation categoryId = new DataRelation ( "categoryId",
myDataSet.Tables [ "Categories" ].Columns [ "CategoryID" ],
myDataSet.Tables [ "Products" ].Columns [ "CategoryID" ], true );
// add the relation to the DataSet.
myDataSet.Relations.Add ( categoryId );
Dim categoryId As New DataRelation ( "categoryId", _
myDataSet.Tables ( "Categories" ).Columns ( "CategoryID" ), _
myDataSet.Tables ( "Products" ).Columns ( "CategoryID" ), true )
' add the relation to the DataSet.
myDataSet.Relations.Add ( categoryId ) |
|
C# |
VB |
DataRelation Members DataRelation Constructor Overload List DataColumn ForeignKeyConstraint RelationName