Need help with Parent/Child table update

  • Thread starter Thread starter Steve Clark
  • Start date Start date
S

Steve Clark

Sorry if this has been addressed before, but I can't find a good reference
for what I'm trying to do.

I'm trying to figure out the "best" way to design and code a windows app.
that allows a user to enter data that will be stored in two related tables
in an Access 2000 database. (ya-ya, I know, use SQL Server...can't right
now).

I've got a grid bound to a typed Data Set. The DS contains two tables
Orders and Items, related by a unique Order ID. Users select a grid row and
the all the data for the cooresponding record is displayed on a data entry
form (unbound) for viewing and/or editing. I'm having problems updating and
deleting child records in the database. Parent rows work OK. I feel like
I'm missing something basic in the handling of Data Sets during updates and
can't find any examples of the best way to handle updates of parent/child
tables using Access. Can someone point me to a good explaination? TIA.

Steve
 
Yup we've talked about this many times. David Sceppa has it in his favorite
responses file.
The basics:
Delete children first
Add, change and delete parents
Add and Update children

This way you don't end up with orphaned children.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
I guess that makes, Bill, thanks. I guess that means I just can't call:
daChild.Update(ds)
daParent.Update(ds)

Does that mean I have to use the ds.GetChanges (dsRowState.xxxx) method to
sift thru the datasets looking for the specifics groups of deleted, modified
or added rows? Seems kind of tedious...no help from the data adaptor wizard
for this?

Steve
 
Right. You have to use the relationships to update just the children and
just the parents. Since they are in separate tables, this is easy--just do
an Update(dtChild)
Sure, filter on the rowstate as well to get the deleted children...

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top