Multi-relational tables in a dataset....

  • Thread starter Thread starter rmorvay
  • Start date Start date
R

rmorvay

I have three tables in a dataset that I need to relate. I know how to
relate two tables but going beyond that is, quite frankly, beyond me. Any
insight? Here is the C# code that I did for a two table relate. I need to
relate TerritoryExceptionColumns as well:

DataColumn[] TerritoryColumns;
DataColumn[] TerritoryExceptionTypeColumns;
DataColumn[] TerritoryExceptionColumns;

TerritoryColumns = new DataColumn[]
{dsTerritory2.Tables["Territory"].Columns["TerritoryID"],
dsTerritory2.Tables["Territory"].Columns["ExceptionType"]};

TerritoryExceptionTypeColumns = new DataColumn[]
{dsTerritory2.Tables["TerritoryExceptionType"].Columns["TerritoryID"],
dsTerritory2.Tables["TerritoryExceptionType"].Columns["ExceptionType"]};

TerritoryExceptionColumns = new DataColumn[]
{dsTerritory2.Tables["TerritoryException"].Columns["TerritoryID"],
dsTerritory2.Tables["TerritoryException"].Columns["ExceptionType"]};

DataRelation drelTerritory = new DataRelation("Territory",
TerritoryColumns, TerritoryExceptionTypeColumns);
dsTerritory2.Relations.Add(drelTerritory);

Thanks in advance.
 
Is this somthing that can't be done or maybe I didn't explain my problem
well enough? I am in a crunch mode so any assistance would greatly be
appreciated.

Thanks,
 
Did you try to create two relations through the parent table "TerritoryColumns" and associate the two children(TerritoryExceptionTypeColumns, TerritoryExceptionColumns) tables through the parent table?

DataRelation drelTerritoryExceptionTypeColumns = new DataRelation("drelTerritoryExceptionTypeColumns",
TerritoryColumns, TerritoryExceptionTypeColumns);
dsTerritory2.Relations.Add(drelTerritoryExceptionTypeColumns );

DataRelation drelTerritoryExceptionColumns = new DataRelation("drelTerritoryExceptionColumns",
TerritoryColumns, TerritoryExceptionColumns);
dsTerritory2.Relations.Add(drelTerritoryExceptionColumns);


rmorvay said:
Is this somthing that can't be done or maybe I didn't explain my problem
well enough? I am in a crunch mode so any assistance would greatly be
appreciated.

Thanks,

--
rmorvay


rmorvay said:
I have three tables in a dataset that I need to relate. I know how to
relate two tables but going beyond that is, quite frankly, beyond me. Any
insight? Here is the C# code that I did for a two table relate. I need to
relate TerritoryExceptionColumns as well:

DataColumn[] TerritoryColumns;
DataColumn[] TerritoryExceptionTypeColumns;
DataColumn[] TerritoryExceptionColumns;

TerritoryColumns = new DataColumn[]
{dsTerritory2.Tables["Territory"].Columns["TerritoryID"],
dsTerritory2.Tables["Territory"].Columns["ExceptionType"]};

TerritoryExceptionTypeColumns = new DataColumn[]
{dsTerritory2.Tables["TerritoryExceptionType"].Columns["TerritoryID"],
dsTerritory2.Tables["TerritoryExceptionType"].Columns["ExceptionType"]};

TerritoryExceptionColumns = new DataColumn[]
{dsTerritory2.Tables["TerritoryException"].Columns["TerritoryID"],
dsTerritory2.Tables["TerritoryException"].Columns["ExceptionType"]};

DataRelation drelTerritory = new DataRelation("Territory",
TerritoryColumns, TerritoryExceptionTypeColumns);
dsTerritory2.Relations.Add(drelTerritory);

Thanks in advance.
 
Back
Top