Greetings!
I’m working with data contained in two tables – a parent table and a child table (1 to many relationship). I’m having trouble with code that will define the relationship on the page so I can implement nested repeaters. I’ve tried several different ways and syntax, all with no success. I’m hoping someone can look at this chunk of code and tell me what I’ve done wrong. Any help is greatly appreciated.
Thanks much!
cmdMbrs = New OleDbCommand( _
“SELECT * ” & _
“FROM tblSubType ” & _
“WHERE (((tblSubType.SubType)=” & strWhere & “))” & _
“ORDER BY tblSubType.SubType;”, conClsf)
cmdMbrs2 = New OleDbCommand( _
“SELECT * ” & _
“FROM tblSubContractors ” & _
“WHERE (((tblSubContractors.SubType)=” & strWhere & “))” & _
“ORDER BY tblSubContractors.SubType;”, conClsf)
Dim DA as OleDbDataAdapter = New OleDbDataAdapter
Dim DA2 as OleDbDataAdapter = New OleDbDataAdapter
DA.SelectCommand = cmdMbrs
Dim ds As DataSet = New DataSet
Dim tblType as DataTable
Dim tblContractors as DataTable
ds.Tables.Add(“tblSubType”)
ds.Tables.Add(“tblSubContractors”)
rdrMbrs = cmdMbrs.ExecuteReader
DA.Fill(“tblSubType”, rdrMbrs)
DA2.SelectCommand = cmdMbrs2
conClsf.close
conClsf.Open
rdrMbrs2 = cmdMbrs2.ExecuteReader
DA2.Fill(“tblSubContractors”, rdrMbrs2)
Dim parentCol As DataColumn
Dim childCol As DataColumn
parentCol = ds.Tables(“tblSubType”).Columns(“SubType”)
childCol = ds.Tables(“tblSubContractors”).Columns(“SubType”)
myRel = New System.Data.DataRelation(“Subs”, parentCol, childCol)
ds.Relations.Add(myRel)
Repeater1.DataSource = ds.Tables(“tblSubType”)
Repeater1.DataBind()
cmdMbrs.Dispose
cmdMbrs2.Dispose
conClsf.Close