asp.net.ph

DataRelationCollection.Add Method ( DataColumn, DataColumn )

System.Data Namespace   DataRelationCollection Class


Adds a DataRelation with the given parent and child columns to the collection.

[ VB ]
Overridable Overloads Public Function Add ( _
   ByVal parentColumn As DataColumn, _
   ByVal childColumn As DataColumn _
) As DataRelation

[ C# ]
public virtual DataRelation Add (
   DataColumn parentColumn,
   DataColumn childColumn
);

[ C++ ]
public: virtual DataRelation* Add (
   DataColumn* parentColumn,
   DataColumn* childColumn
);

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

Parameters

parentColumn
The parent column of the relation.
childColumn
The child column of the relation.

Return Value

The newly created DataRelation.

Exceptions


Exception Type Condition
ArgumentException Occurs when the relation already belongs to this collection, or it belongs to another collection.
InvalidConstraintException Occurs when the relation cannot be created based on the given parameters.

Remarks

This version of the Add method creates a relation given the above parameters and adds it to the collection. The name is defaulted. The CollectionChanged event is fired if it succeeds.

Example

The following example adds a new DataRelation using this version of the Add method.

ds.Relations.Add (
   ds.Tables [ 0 ].Columns [ "CategoryID" ], 
   ds.Tables [ 1 ].Columns [ "CategoryID" ] );
  C# VB

See Also

DataRelationCollection Members   DataRelationCollection.Add Overload List 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