Associating Related Tables with the DataRelation Class

One of the most powerful aspects of ADO.NET—and, specifically, of the DataSet class—is the ability to define relationships between related tables such that both tables can be navigated more easily and efficiently. For example, let's say you have a typical order entry system with both an OrderHeaders and OrderDetails table. In fact, the sample database (ExtendingMFCWithDotNet) provided on the CD with this book contains two such tables whose schemas are shown in Tables 7-2 and 7-3.

Table 7-2. Sample OrderHeaders Table Schema
Primary Key (y/n)IDENTITY (y/n)Column NameType
YESYESOrderIdint
  CompanyNamevarchar
  ShippingAddressvarchar
Table 7-3. Sample OrderDetails Table Schema
Primary Key (y/n)

Get Extending MFC Applications with the .NET Framework 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.