Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Apple, tomato, lettuce -- hierarchical recordsets???
Message
From
16/05/2001 01:21:41
 
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00507652
Message ID:
00507693
Views:
11
>>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

actually i have done that code before bringing the issue on UT, unfortunately that wouldn't work. Hierarchical recordsets doesn't support adding/editing of records.
If you want to try it yourself:
rsTempChild.Supports(adAddNew) --> returns FALSE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform