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 ... |
Get Sams Teach Yourself ADO.NET in 24 Hours now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.