Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge datasets in a datagrid

Status
Not open for further replies.

Dronealone

IS-IT--Management
Mar 13, 2002
64
GB
hi,

i have 3 datasets that I want to merge into a single datagrid with collapsible rows(optional!).

The 3 datasets contain a single tables which are related to each other by primary key.

how can I combine these?

Any help much appreciated.

thanks
 
Is there any reason for making it into 3 different dataset? If you can make it into one then you can use DataRelation to achieve what you are looking for

Example from MSN

Code:
Dim CustomersOrders As New DataRelation("CustomersOrders", _
    DsNorthwind1.Customers.Columns("CustomerID"), _
    DsNorthwind1.Orders.Columns("CustomerID"))
DsNorthwind1.Relations.Add(CustomersOrders)

As you can see Customers and Orders are two datatable in the dataset DsNorthwind1. Same like this you can add one more relation to your third datatable and setting the dataset as datasource of your datagrid will automatically create collapsible rows.

-Kris
 
...Or create a stored procedure (or SQL query string) that joins the three tables in the way that you need (a little bit less of a hit on your server).

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
The reason for the 3 is that the code I am working with has already implemented this method, done all the (very complicated) SQL etc. There are 3 objects which each expose a dataset. These objects are related via database columns, and I wanted to combine using a dataset. Is the easiest way to go back and rebuild the SQL ?
 
I'd tend to say that if you are able to... Yes.

It may not be the easiest, but it'll be the best way.

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top