Tim Kelley wrote:
> I have two tables that are linked by 2 fields (ID1 and ID2). Is it possible
> to create this relation once the tables are in a DataSet? I can create a
> relation using a single field, but I don't know if this is possible with
> multiple fields.
>
> Thanks,
Hi,
This is how you can do .... I have given code snippet. I think
this will be useful for your problem.
DataSet ds;
DataTable dt1;
DataTable dt2;
ds.Tables.Add(dt1);
ds.Tables.Add(dt2);
DataRelation dr1 = new DataRelation("ID1 RELATION",
"PARENTID1", "CHILDID1");
dr1.ParentTable = dt1;
dr1.ChildTable = dt2;
DataRelation dr2 = new DataRelation("ID2 RELATION",
"PARENTID2", "CHILDID2");
dr2.ParentTable = dt1;
dr2.ChildTable = dt2;
ds.Relations.Add(dr2);
|