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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid with several datatables

Status
Not open for further replies.

NeilV

Programmer
Oct 14, 2002
117
GB
Hello.

I am trying to create a datagrid that has the results of several datatables. Each datatable contains a partnumber and quantity. I would the the row in the datagrid to contain the partnumber and then the quantity of this partnumber from each of the tables, effectively join the tables. How can i do this? I cant do it in SQL as the datatables are coming from different datasources.

Thanks,

Neil
 
use a dataset.

create a datatable for each source.

create datarelations between the tables...

Known is handfull, Unknown is worldfull
 
vbkris,

I see this post (and the solution you have given) is a real life example of a good use for a DataSet that we discussed in thread855-1080680 (in which I said one of it's main uses was "when you have a table from one data source that has a relationship to a table in another data source").


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks for the help guys. However, i cant seem to get it to work, i have the following code:

Code:
DataRelation dr = allData.Relations.Add("ProdShip",allData.Tables["Produced"].Columns["Partnumber"],allData.Tables["Shipped"].Columns["Partnumber"]);
dgInfo.DataSource = allData;
dgInfo.DataBind();

but the datagrid only displays the results in one of the datatables. What am i doing wrong?
 
It would be easier to write a stored procedure that returns one dataset. Then use that to bind to your grid.
 
Sadly i cant write a stored procedure to do this as the datatables are being populated by different databases, one on SQL Server and the other on an AS400...
 
>>is a real life example of a good use for a DataSet that we discussed in thread855-1080680

yup infact picked that idea only from there...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top