Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 824304 - Last Review: December 9, 2003 - Revision: 1.2
The Depth property of the Level object always returns -1
The
Depth property of an instance of the
Level object always returns
-1 instead of the actual depth level.
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.
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 workaroundMicrosoft is aware of this problem. This problem might be fixed in a future version of the products in the "Applies to" section.
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
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate