asp.net.ph

DataRelationCollection.Add Method ( DataRelation )

System.Data Namespace   DataRelationCollection Class


Adds a DataRelation object to the collection.

[ VB ]
Overloads Public Sub Add ( _
   ByVal relation As DataRelation _
)

[ C# ]
public void Add (
   DataRelation relation
);

[ C++ ]
public: void Add (
   DataRelation* relation
);

[ JScript ]
public function Add (
   relation : DataRelation
);

Parameters

relation
The DataRelation to add.

Exceptions


Exception Type Condition
ArgumentNullException Occurs when the relation argument is null.
ArgumentException Occurs when the relation already belongs to this collection, or it belongs to another collection.
DuplicateNameException Occurs when the collection already has a relation with the specified name. The comparison is case insensitive.
InvalidConstraintException Occurs when the relation has entered an invalid state since it was created.

Remarks

If the relation is sucessfully added to the collection, the CollectionChanged event occurs.

Example

The following example adds a new DataRelation using this constructor.

DataRelation categoryId = new DataRelation (
   ds.Tables [ 0 ].Columns [ "CategoryID" ], 
   ds.Tables [ 1 ].Columns [ "CategoryID" ] );
ds.Relatons.Add ( 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