ramu
ramu

Reputation: 1029

Create hierarchical recordset

How can we create a hierarchical recordset without using SHAPE Command of MSDATASHAPE Provider?

Upvotes: 0

Views: 1276

Answers (1)

Bob77
Bob77

Reputation: 13267

As far as I can determine there is no direct way to accomplish this via the object model, i.e. without using the Data Shaping Service (Provider) and the Recordset.Open method.

As the documentation says though you can still use it to fabricate hierarchical Recordsets. Here is the example given:

Dim cn As New ADODB.Connection
Dim rsCustomers As New ADODB.Recordset

cn.Open "Provider=MSDataShape;Data Provider=NONE;"

strShape = _
"SHAPE APPEND NEW adInteger AS CustID," & _
            " NEW adChar(25) AS FirstName," & _
            " NEW adChar(25) AS LastName," & _
            " NEW adChar(12) AS SSN," & _
            " NEW adChar(50) AS Address," & _
         " ((SHAPE APPEND NEW adChar(80) AS VIN_NO," & _
                        " NEW adInteger AS CustID," & _
                        " NEW adChar(20) AS BodyColor, " & _
                     " ((SHAPE APPEND NEW adChar(80) AS VIN_NO," & _
                                    " NEW adChar(20) AS Make, " & _
                                    " NEW adChar(20) AS Model," & _
                                    " NEW adChar(4) AS Year) " & _
                        " AS VINS RELATE VIN_NO TO VIN_NO))" & _
            " AS Vehicles RELATE CustID TO CustID) "

rsCustomers.Open strShape, cn, adOpenStatic, adLockOptimistic, -1

You should find this right in your MSDN Library CD documentation.

Upvotes: 2

Related Questions