O'Reilly logo

Sams Teach Yourself ADO.NET in 24 Hours by Paul Bertucci, Jason Lefebvre

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The DataSet Relations Collection

The DataSet contains a collection of DataRelation objects named, appropriately enough, DataRelationCollection. This collection stores all DataRelations for the DataTables in your DataSet. There's no practical limit to the number of relationships you can add to a DataSet.

Adding a Relationship Between Two DataTables

Adding a relationship between two DataTables is straightforward. You can simply add a new DataRelation object to the Relations collection of your DataSet as in Listing 4.4. The first argument to the Add() method is the name of the relationship. The second argument contains the parent DataColumn. The third argument contains the child DataColumn of the relationship.

The parent is defined as the column ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required