asp.net.ph

DataRelation Constructor ( String, DataColumn, DataColumn )

System.Data Namespace   DataRelation Class


Initializes a new instance of the DataRelation class using the specified DataRelation name, and parent and child DataColumn objects.

[ VB ]
Overloads Public Sub New ( _
   ByVal relationName As String, _
   ByVal parentColumn As DataColumn, _
   ByVal childColumn As DataColumn _
)

[ C# ]
public DataRelation (
   string relationName,
   DataColumn parentColumn,
   DataColumn childColumn
);

[ C++ ]
public: DataRelation (
   String* relationName,
   DataColumn* parentColumn,
   DataColumn* childColumn
);

[ JScript ]
public function DataRelation (
   relationName : String,
   parentColumn : DataColumn,
   childColumn : DataColumn
);

Parameters

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.

Exceptions


Exception Type Condition
ArgumentNullException Occurs when either one or both of the DataColumn objects is a null reference ( Nothing ).
InvalidConstraintException Occurs when
  • the columns have differing data types
  • the tables do not belong to the same DataSet.

Example

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" ] );

   // add the relation to the DataSet.
   myDataSet.Relations.Add ( categoryId );
  C# VB

 Show me 

See Also

DataRelation Members   DataRelation Constructor Overload List   DataColumn   RelationName Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph