Displaying data from 2 tables in one datagridview

L

Lars E.

Hi all.

i am trying to display contents from 2 tables in one datagridview.

It is not possible for me to do a join, so i have to combine 2 datatables to be able to show data from both tables.

My tables are: "Customer" and "Customer Contact".

The relation is: Customer.c-Customerno = CustomerContract.cc-Customerno (the primary key names are not the same)

I want to display customers with the customers contact information.

Do i have to create a new datatable and populate this from det different tables in my dataset.
(ds.tables[0] and ds.tables[1]).

How can i do this. Please help.
 
L

Lars E

Thanks, but that link was to VB-Help.

Perhaps i made a request in the wrong newsgroup.

I am trying to do this in C#.
Should i use another newsgroup?

Lars E.
 
C

Cor Ligthert [MVP]

So much difference is there not between VBNet and C#

To take the main solution in the sample

\\\
ds.Relations.Add("MyRelation", dt1.Columns["TheRelation"],
dt2.Columns["TheRelation"]);
dt2.Columns.Add("State", Type.GetType("System.String"), "Parent.State");
DataGridView1.DataSource = dt2;
///
Roughly done,

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