创建分层记录集

时间:2011-04-08 07:10:24

标签: vb6 ado

如何在不使用MSDATASHAPE Provider的SHAPE命令的情况下创建分层记录集?

1 个答案:

答案 0 :(得分:2)

据我所知,没有直接的方法可以通过对象模型实现这一点,即不使用数据整形服务(Provider)和Recordset.Open方法。

正如文档所说,尽管您仍然可以使用它来制作分层Recordset。以下是给出的示例:

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

您应该在MSDN Library CD文档中找到这一点。