Can you help my problem?
I have 2 tables : product (as parent) and sales (as a child).
product table consists of:
product_id | product_name | product_price |
1 | book | $5 |sales table consist of:
transaction_id | product_id | quantity | total_price |
A001 | 1 | 10 | $50 |
- product_id at the product table is pK for product table.
- transaction_id at the sales table is pK for sales table .
- product_id at the sales table as fK, which a reference to the product_id of product table
All my tables are stored in the dataset. How do I get the data from these datasets can I view on the DataGridView with a different layout formats, as follows.
transaction_id | product_name | product_price | quantity | total_price |
A001 | book | $5 | 10 | $50 |
Thanks & Best Regards,
YDA
Can you write your query to populate your dataset in the format you want? If so, I think you can just databind the resulting datatable to the DataGridView and get what you want. So your query would be something like:
Of course, you would replace $5 and so on with the actual column names. Use that query to populate a dataset, then on your form.
Where “MyJoinedDataTable” is the name of the table that you populated in the dataset.