E
EricJ
Hi all
im a bit confused here, I m trying to add the rows from 1
dataset.tables(0).rows to another ds2.tables(0).rows.add(row) there is
probably a better way to do this than going looping true the rows (if you
know tell me ;p), but that is how im trying to do this atm.
at a certain point i get an error message : This row already belongs to
another table.
i dont know w i am doing wrong (not that it is nice code but i added it
below anyway)
i'll try to explain the situation a bit, i have groups that can contain
elements or other groups and i have to go true a group to c if it has
subgroubs, then go true the subgroups ... there is no way to tell how many
levels there will be. I'm not even sure if it isn't possible to create an
sql statement to get the data all sugestions are welcome.
tnx
--
Juchtmans Eric
Omnipack
Private Function filterGroepen(ByVal gr As clsArtGroep) As DataSet
Try
Dim ds As DataSet
ds = SqlHelper.ExecuteDataset(gstrCnn, CommandType.Text, "Select artgdArtgID
from tblArtgroepdeel where artgdArtgID <> 0 " & _
"and artgdMainArtgID = " & gr.ID & "")
Dim rij, rij2,r As DataRow
Dim dssub As DataSet
Dim g As New clsArtGroep
For Each rij In ds.Tables(0).Rows
g.ID = (CInt(rij(0)))
dssub = filterGroepen(g)
For Each rij2 In dssub.Tables(0).Rows
r = rij2
ds.Tables(0).Rows.Add(r)
Next
Next
Return ds
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
structure of the tables to give you an idea (not complete)
tblMAIN (ID, NAME)
tblSUB (ID, MAINID, ELEMENT, SUBID) (or element is filled in or SUBID)
im a bit confused here, I m trying to add the rows from 1
dataset.tables(0).rows to another ds2.tables(0).rows.add(row) there is
probably a better way to do this than going looping true the rows (if you
know tell me ;p), but that is how im trying to do this atm.
at a certain point i get an error message : This row already belongs to
another table.
i dont know w i am doing wrong (not that it is nice code but i added it
below anyway)
i'll try to explain the situation a bit, i have groups that can contain
elements or other groups and i have to go true a group to c if it has
subgroubs, then go true the subgroups ... there is no way to tell how many
levels there will be. I'm not even sure if it isn't possible to create an
sql statement to get the data all sugestions are welcome.
tnx
--
Juchtmans Eric
Omnipack
Private Function filterGroepen(ByVal gr As clsArtGroep) As DataSet
Try
Dim ds As DataSet
ds = SqlHelper.ExecuteDataset(gstrCnn, CommandType.Text, "Select artgdArtgID
from tblArtgroepdeel where artgdArtgID <> 0 " & _
"and artgdMainArtgID = " & gr.ID & "")
Dim rij, rij2,r As DataRow
Dim dssub As DataSet
Dim g As New clsArtGroep
For Each rij In ds.Tables(0).Rows
g.ID = (CInt(rij(0)))
dssub = filterGroepen(g)
For Each rij2 In dssub.Tables(0).Rows
r = rij2
ds.Tables(0).Rows.Add(r)
Next
Next
Return ds
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
structure of the tables to give you an idea (not complete)
tblMAIN (ID, NAME)
tblSUB (ID, MAINID, ELEMENT, SUBID) (or element is filled in or SUBID)