Question Populate a datagridview control with fields from two datatables in the same dataset

smbrush

Member
Joined
Dec 16, 2013
Messages
5
Location
Philadelphia, PA
Programming Experience
10+
Can anyone tell me how to code a selection of fields from two related tables in a dataset and populate a datagrid view control on a form with fields from both parent and child tables? A ADO.DB relation object can be added to the dataset. What then? Is there a way to populate the datagridview without first creating a new table and populating that by going row by row in the parent table?
 
A DataGridView can only display data from one list. You need to create a new DataTable that contains the combined data. You can do that by either querying the database directly or you can do it in VB code. If you do it in VB then you should use LINQ because the code will be much more concise. Like SQL, LINQ supports joins.
 
Back
Top