Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The Depth property of the Level object always returns -1


View products that this article applies to.

Symptoms

The Depth property of an instance of the Level object always returns -1 instead of the actual depth level.

↑ Back to the top


Cause

This problem occurs because the code that maps Microsoft SQL Server 2000 Analysis Services internal data types into VARIANT subtypes has changed. The VARIANT subtype that is assigned to the value that represents the depth level has changed. Because the GetSchemaObject method does not support the new subtype for the Depth property, GetSchemaObject ignores the new value and leaves the default value of -1. This value is assigned by the constructor of the Level object.

↑ Back to the top


Workaround

To work around this problem and obtain the actual depth level, use the LevelDepth property of the first member of the Level object. To do so, use the following code:
Dim oLevel As ADOMD.Level
    Dim oMember As ADOMD.Member
    Dim oCellset As ADOMD.Cellset
    Dim lMembLvDepth As Long
    Dim lLevelDepth As Long
    Dim oCube As ADOMD.CubeDef
    Set oCatalog = New ADOMD.Catalog
    oCatalog.ActiveConnection = "Provider=MSOLAP;Data Source=localhost;Initial Catalog=Foodmart 2000"
    Set oCube = oCatalog.CubeDefs("Warehouse")
    Set oLevel = oCube.GetSchemaObject(adObjectTypeLevel, "[Store].[Store Name]")
    Debug.Print oLevel.Members(0).LevelDepth 'This is the suggested workaround

↑ Back to the top


Status

Microsoft is aware of this problem. This problem might be fixed in a future version of the products in the "Applies to" section.

↑ Back to the top


More information

To reproduce this problem, use the following code:
Dim oLevel As ADOMD.Level
    Dim oMember As ADOMD.Member
    Dim oCellset As ADOMD.Cellset
    Dim lMembLvDepth As Long
    Dim lLevelDepth As Long
    Dim oCube As ADOMD.CubeDef
    Set oCatalog = New ADOMD.Catalog
    oCatalog.ActiveConnection = "Provider=MSOLAP;Data Source=localhost;Initial Catalog=Foodmart 2000"
    Set oCube = oCatalog.CubeDefs("Warehouse")
    Set oLevel = oCube.GetSchemaObject(adObjectTypeLevel, "[Store].[Store Name]")
    Debug.Print oLevel.Depth ' This returns -1, which is not the actual depth level

↑ Back to the top


Keywords: KB824304, kbprb

↑ Back to the top

Article Info
Article ID : 824304
Revision : 3
Created on : 12/9/2003
Published on : 12/9/2003
Exists online : False
Views : 374