Question help with child table newrow in dataset

ghardy

Member
Joined
Mar 18, 2010
Messages
20
Programming Experience
10+
hi all,

i have a dataset in my application (vb.net2008) that has a parent table with some child tables linked with a relationship. i would like to be able to open the form in "new" mode, and allow the user to create the whole dataset, and hit the save button once, but this isn't working for me.

what happens is i have a link button that allows them to add "labor resources" to the child grid, but when i try to do the addnewitemrow, it says "no position at row 0." i assume this is because the parent record hasn't been saved, and therefore, does not yet have a rowhandle.

AddLaborRow(dsSpread.Spread.Rows(0), field, field, ....)

is there a trick to doing this? right now, i open the form, let them fill in the parent table info, then force them to save it before enabling the child grid and allow additions there. this seems cheesy to me though.

thanks!
 
Last edited:
If you want to add child records then there must be a parent record, plain and simple. The only requirement is that there's a parent record in the DataSet though. You can't add child records to the DataSet until you've added the parent record to the DataSet and you can save child records to the database until you've added the parent record to the database. They are two independent steps.
 
ps; if that thread doesnt make sense:

Unlink the (add new ) on the binding navigator, and control the addnew yourself

call Parent.AddNew() then immediately Parent.EndEdit()

Then do the same for the child

Then allow the user to edit the data
 
Back
Top