Why is this code generating an error?
Dim ds As New DataSet
Dim tMaster As New DataTable(“TableMaster”)
Dim idMPmaster As DataColumn = tMaster.Columns.Add(“IdMP”, GetType(String))
tMaster.Columns.Add(“Order”, GetType(Integer))
tMaster.PrimaryKey = New DataColumn() {idMPmaster}
ds.Tables.Add(tMaster)
Dim tDetail As New DataTable(“TableDetail”)
Dim cidDetail As DataColumn = tDetail.Columns.Add(“id”, GetType(Integer))
Dim cidMPDetail As DataColumn = tDetail.Columns.Add(“idMP”, GetType(String))
Dim cOrder As DataColumn = tDetail.Columns.Add("Order", GetType(Integer))
tDetail.PrimaryKey = New DataColumn() {cidDetail, cidMPDetail}
ds.Tables.Add(tDetail)
ds.Relations.Add("Rel", idMPmaster, cidMPDetail)
tMaster.Rows.Add(“A”, 10)
tMaster.Rows.Add(“B”, 20)
tMaster.Rows.Add(“C”, 30)
tDetail.Rows.Add(1, “A”)
tDetail.Rows.Add(1, “B”)
tDetail.Rows.Add(2, “B”)
tDetail.Rows.Add(2, “C”)
tDetail.Rows.Add(3, “A”)
tDetail.Rows.Add(3, “B”)
tDetail.Rows.Add(3, “C”)
' Without this line there will be no error
cOrder.Expression = "Parent(Rel).Order"
' This line generate an error: cannot find parent relation Rel
Dim changes tDetail.GetChanges()
Why does the last line of the code generate an error:
cannot find parent relation
Rel