Pseudocode:

1. Create Primary keys on both tables.
2. Create a DataRelation between both tables, specifying the Primary
key and the Foreign key column.
3. Create the schema for the target (third) table.
4. Iterate within the Rows of  the Child Table (Table2), creating New
Rows in Table3 and assigning its columns from the Table2.
5. When you need the columns of the Parent table, use the GetParentRow
() method to get the related Parent Row for this Child Row. Then
assign it's relevant columns to the the related columns in Table3.
6. "Add" the newly created Row to the Table3 for each iteration.

Sorry, I'm famished right now... and can't really bring myself to
write that amount of code. You should have no problem finding any
amount of code samples online. A much better option than this is
usually to retrieve a JOINed table from the Datasource itself. (SQL
Join).

On Nov 13, 11:45 am, Vivienne <[EMAIL PROTECTED]> wrote:
> Hi,
>
>    I am stuck when I am trying to displaying a dataset with multiple
> tables in DataGrid. I would like to display some columns in Table A,
> and some columns in table B, table B is the child table of table A.
>
>     When come to displaying, I create another DataTable, and try to
> copy the columns I want from table A and table B, and want to combine
> the columns into one table. Like below:
>
>      DataTable newTable = new DataTable();
>      newTable.columns.add(tableA.columns["abc"]);
>      newTable.columns.add(talbeB.columns["edf"]);
>
>  But I faild with the error "Column *** already belongs to another
> DataTable."  I know that DataColumn is an reference object and a
> reference can't can't be added to another table. Then there is no way
> to copy a  column(I expected to have this: tableA.columns["abc"].copy
> () ).
>
>   I just want to display data from multiple tables. What should I do?
> Any suggestions will be appreciate.
>
> Vivienne Zhou

Reply via email to