Introduction
The way to stablish a System.Data.DataRelation betwin 2 System.Data.DataTable's by 2 or more System.Data.datacolumn's.
In this example u must asume the existence of 2 DataTables in the DS_Geral DataSet with the acording fields ...
Sub Ex()
Dim DR_Afectacao_Producao as System.Data.DataRelation
Dim Parent (1) as System.Data.datacolumn
Dim Child (1) as System.Data.datacolumn
Parent (0) = DT_Afectacao.Columns("id_prod") Parent (1) = DT_Afectacao.Columns("id_xnuc") Child (0) = DT_Producao.Columns("id_prod") Child (1) = DT_Producao.Columns("id_xnuc")
DR_Afectacao_Producao = new Datarelation ("Afect_Producao", Parent, Child, _<BR> false )
DS_Geral.Relations.Add(DR_Afectacao_Producao)
End Sub
Example 1 Geting the Child Rows:Dim ChildRows_1(), foundRow As DataRow
foundRow = DT_Afectacao.Rows.Find(Sender.Selecteditem.value)
ChildRows_1 = foundRow.GetChildRows("Afect_Producao")Result: ChildRows_1 is an Array of all of the child Rows ...
Example 2 Geting the Parent row:
Dim founded_ParentRow , foundRow As DataRow
foundRow = DT_Producao.Rows.Find(Sender.Selecteditem.value)
founded_ParentRow = foundRow.GetParentRow("Afect_Producao")Result: foundParentRow is a DataRow in the parent DataTable of the relation ...
Summary:
The "Rows.Find" only finds key-values ... in the key-column of the DataTable