Article ID: 824304 - Last Review: December 9, 2003 - Revision: 1.2

The Depth property of the Level object always returns -1

Expand all | Collapse all

SYMPTOMS

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

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.

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

STATUS

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

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

APPLIES TO
  • Microsoft Data Access Components 2.7
  • Microsoft Data Access Components 2.8
Keywords: 
kbprb KB824304
 

Article Translations