Is it possible to add more than one DataRelation to a DataSet? I need three columns in separate tables to be related.
Is it possible to add more than one DataRelation to a DataSet? I need three columns in separate tables to be related.
I solved it like this:
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);