MDAC 2.5 SDK - OLE DB Providers
Data Shaping Service for OLE DB


 

Requerying and Resynching the Hierarchy

                   

ADO provides a number of means to fetch fresh data for the child rows of a hierarchy.

Executing the Requery method on any Recordset in the hierarchy will close and reopen the Recordsets involved. This includes all associated Recordset data.

The next example shows a hierarchy of customers built to include child rows of orders. rsOrders.Requery will close that Recordset and all orders.* Recordsets. The command as recorded in the Command object will execute again, and a new hierarchy will be built. The Requery method is useful when the possibility of changes to all queried data store tables exists.

Simple Relation-Based Hierarchy Example

SHAPE {select * from Customers}
   APPEND ({select * from Orders} 
      AS ChpOrders 
   RELATE cust_id to cust_id) 
      AS ChpOrders

This results in the following hierarchy:

Executing the Resync method on a parent row causes the child Recordset chapter to be cleared but not deleted. This causes the child rows to be reassociated when the parent row is accessed. This is useful when the "relating" field in the parent row is altered, causing the child chapter membership to change.

For example, if a hierarchy of customers is built to include child rows of orders, as in the previous code sample, and the field cust_id in the parent row is altered, the child rows would not be related to the present parent. When rsOrders.Resync is executed, the child rows are cleared, forcing the application to fetch a new set of child rows.