The following example shows the steps necessary to access rows in a hierarchical Recordset:
Example
Sub datashape()
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim rsChapter As Variant
cnn.Provider = "MSDataShape"
cnn.Open "Data Provider=MSDASQL;" & _
"DSN=vfox;uid=sa;pwd=vfox;database=pubsö
'STEP 1
rst.Open "SHAPE {select * from authors}
APPEND ({select * from titleauthor} AS chapter
RELATE au_id TO au_id)",
cnn
'STEP 2
While Not rst.EOF
Debug.Print rst("au_fname"), rst("au_lname"),
rst("state"), rst("au_id")
'STEP 3
rsChapter = rst("chapter")
'STEP 4
While Not rsChapter.EOF
Debug.Print rsChapter(0), rsChapter(1),
rsChapter(2), rsChapter(3)
rsChapter.MoveNext
Wend
rst.MoveNext
Wend
End Sub
Parameterized Commands
Shape commands may be parameterized. That is, you may specify:
"SHAPE {select * from customer} APPEND
({select * from orders where cust_id = ?} AS rsOrders
RELATE cust_id TO PARAMETER 0)"
This accounts for the case where ...