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


 

Controlling Freshness of Child Results

                   

Controlling freshness of child results is not possible for group-based and relation-based hierarchies. For these two types, the data is retrieved in its entirety as requested, once the connection is made and the SHAPE command invoked. By default, the cursor engine, or specifically the Cursor Service for OLE DB, caches the fetched rows before any hierarchy building is attempted. These cached rows are used when the parent row is accessed. Executing the SHAPE command again will fetch the current data from your data provider, creating a new result set. Any existing result sets are unaffected.

For parameter-based hierarchies, the Data Shaping Service fetches each child result when a new parent is selected. To control ADO child Recordset freshness in this type of hierarchy, set the ADO dynamic property Cache Child Rows (Boolean). This property is included in the Properties collection of the Recordset object. The default is True, meaning child rows will be kept when the chapter is released.

Setting this property to False forces the cursor engine to query the server to obtain the current child row—the same as when building parameter-based hierarchies. If Cache Child Rows is False, the rows in the child Recordset are discarded when the chapter is released. If the chapter is reopened, the parameterized command is reexecuted, fetching fresh results from the data provider.

The following example shows how to force the cursor engine to retrieve child rows for each parent as needed:

Debug.Print rs.Properties("Cache Child Rows")
rs.properties("Cache Child Rows") = False