N
Nathan
Hi guys,
I need to know how to create child rows for a newly created parent row.
I've been doing it one way, but it's obviously not the right way to do it
(finally starting to cause me some problems!). Here's what I've been doing
("ParentID" is the primary key):
\\
Dim NewParent as DataRow = tblParentTable.NewRow
'<Initialize NewParent values>
tblParentTable.Rows.Add(NewParent)
Dim NewChild as DataRow = tblChildTable.NewRow
NewChild.Item("ParentID") = CInt(NewParent.Item("ParentID"))
'<Initialize other NewChild values>
tblChildTable.Rows.Add(NewChild)
//
What happens is, the dataset creates a "temporary" value for ParentID, and
that value is assigned to the child rows. So the relationship works okay
until the database is updated and then the tables refilled. On update, the
database sometimes gives a different value for ParentID than the database
had, but that value change is not carried through to the child rows.
What is the proper way to do this?
Thanks,
Nathan
I need to know how to create child rows for a newly created parent row.
I've been doing it one way, but it's obviously not the right way to do it
(finally starting to cause me some problems!). Here's what I've been doing
("ParentID" is the primary key):
\\
Dim NewParent as DataRow = tblParentTable.NewRow
'<Initialize NewParent values>
tblParentTable.Rows.Add(NewParent)
Dim NewChild as DataRow = tblChildTable.NewRow
NewChild.Item("ParentID") = CInt(NewParent.Item("ParentID"))
'<Initialize other NewChild values>
tblChildTable.Rows.Add(NewChild)
//
What happens is, the dataset creates a "temporary" value for ParentID, and
that value is assigned to the child rows. So the relationship works okay
until the database is updated and then the tables refilled. On update, the
database sometimes gives a different value for ParentID than the database
had, but that value change is not carried through to the child rows.
What is the proper way to do this?
Thanks,
Nathan