创建分层记录集

发布于 2024-10-31 16:10:50 字数 57 浏览 0 评论 0原文

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牵强ㄟ 2024-11-07 16:10:50

据我所知,没有直接的方法可以通过对象模型来完成此操作,即不使用数据整形服务(提供程序)和 Recordset.Open 方法。

正如文档所述,您仍然可以使用它来构建分层记录集。下面是给出的示例:

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 文档中找到它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文