Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Apple, tomato, lettuce -- hierarchical recordsets???
Message
 
À
15/05/2001 21:08:59
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00507652
Message ID:
00507682
Vues:
8
>good day! i'm having trouble with parent-child relationship. one typical exampleis the ITEM_CATEGORY & ITEM:
>
>ITEM_CATEGORY
>- item_cat_code (primary key)
>- item_cat_desc
>
>ITEM
>- item_cat_code (foreign key)
>- item_code (primary key)
>- item_desc
>
>i'm using ADO recordsets (rsItem_Category & rsItem), how do i make my rsItem automatically contain the related records everytime my rsItem_Category moves to another row.
>to illustrate here's a sample data:
>rsItem_Category
>item_cat_code item_cat_desc
>FRTS FRUITS
>VEGE VEGETABLES
>
>rsItem
>item_cat_code item_code item_desc
>FRTS APPL APPLE
>VEGE TOM TOMATO
>VEGE LET LETTUCE
>
>as i was saying, when rsItem_Category is in the second record (item_cat_code = 'VEGE'), rsItem should have these records (item_code = 'TOM', item_code = 'LET').
>
>when i was programming in visual foxpro, i use the data environment and add the two tables, then i relate the two tables by dragging the ITEM_CATEGORY.item_cat_code to ITEM.item_cat_code.
>
>how do i do this in visual basic?
>i know how to use hierarchical recordsets (data shaping), but the problem is that i can't edit/addnew/update the records.
>am i missing something on hierarchical recordsets? or is there any other way to do this?


The Item recordset is a child of the Category recordset. To be able to play with the child (display, add, delete, update), you need to copy the child to another temp recordset. Open your Category recordset (which will contain the hierarchy), loop through the category recordset and when you need to play with the child recordset, do this:
Set rstTempChild = rstCategory.Fields("Item").Value
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform