|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How select from 2 ADO.NET DataTables?ADO.NET DataSet (dstPublish). tblAuthor has DataColumns AuthorID and AuthorName, tblBook has DataColumns BookID, BookTitle, AuthorID (assume a book can be written by only one author). tblAuthor --------- 1 Ayn 2 Jim 3 Sue tblBook ------- 10 Fountainhead 1 11 Atlas Shrugged 1 12 Moby Dick 2 I want to create a list of all books with their associated author name. FountainHead Ayn Atlas Shrugged Ayn Moby Dick This is a breeze in SQL for me, but I'm not sure how to go about using ADO.NET DataTables. Do I need a DataRelation, or is it just a matter of having a for loop within a for loop, or is it something else? Thanks, Ron >Do I need a DataRelation, or is it just a matter of You can create a DataRelation. The DataRow has methods for navigation>having a for loop within a for loop along the data relation like GetParentRows, GetParentRow, GetChildRows, etc. Something like this: dataSet.Relations.Add(tblAuthor.Columns["ID"], tblBooks.Columns["AuthorID"]); Change the column names appropriately. foreach (book row in tblBookx) { Row authorRow = row.GetParentRow(); } You still have to loop, but it simplifies parent looking-up by removing the inner loop. Thi
Other interesting topics
Effective strategy for using VSS in a development team?
Getting Event of Lock Windows OS Application Idle - Good or bad practice? Why won't you give me your scrollbars?! I hate you, TreeView! C++ class in DLL to be imported to C# How to: Access the Managed HTML Document Object Model Getting text box value on key press? Finding if a column is unique in a dataset Visual C# FileIO and Environment Permission PP: Identifying list of unwanted USINGs |
|||||||||||||||||||||||