How to add more than one Datarelation to a Dataset in C#?

Asked

Viewed 98 times

0

Is it possible to add more than one Datarelation to a Dataset? Need three columns in separate tables to be related.

1 answer

0


I resolved so:

DataTable parentDtbl = new DataTable();
DataTable childDtbl = new DataTable();    

parentDtbl = RetornarData1();
childDtbl = RetornarData2();

DataSet dtSet = new DataSet();
dtSet.Tables.AddRange(new DataTable[] { parentDtbl, childDtbl });

DataRelation relation = new DataRelation("relation",
                        new DataColumn[] { dtSet.Tables[0].Columns[0], dtSet.Tables[0].Columns[1], dtSet.Tables[0].Columns[2] },
                        new DataColumn[] { dtSet.Tables[1].Columns[0], dtSet.Tables[1].Columns[1], dtSet.Tables[1].Columns[2]}, false);

dtSet.Relations.Add(relation);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.