ADO.net 2.0, beta 2, how to get data from 2 tables, not parent-chi

G

Guest

in ADO.net 2.0 beta 2
I know how to do the parent-child type.
1. drag a DataGrid control in a window form, get a datasource from
table cust.
2. drag table cust onto the DataGrid.
3. in the data window, right-click the dataset, select configure..
adding table o.
4. drag the child table onto the DataGrid control.
comment: With this way, I build this without a coding. I believe it is
MVC style.
I do not know the steps to join two relational tables into one ADO
table.Please advise. Thanks.
Peter
 
S

Sahil Malik [MVP]

If you want a single datatable driven out of two database tables, the best
way to do that is to simply execute a join query on the database.

If you wish to combine two datatables to give you one single datatable, the
best way to do that is to iterate over values of both tables and use the
LoadDataRow method.

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
 
C

Cor Ligthert [MVP]

Peter,

If it is a one to one relation you can use the merge.

Be aware that the keys have to be equal and that the collecting table has to
have all columns you need (probably is the best to do two merges in a new
created datatable).

(I don't think that you can do this with drag and drop)

Here a simple sample that can lead you in my opinion to your solution.

http://www.windowsformsdatagridhelp.com/default.aspx?ID=edb1409d-5394-468f-a63f-de3a5d92b14a

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top