Hello Everyone,

I trying to programmatically add a Dimension to my OLAP database and have run
into difficulty with a MemberKeyColumn.

I started by creating my new Dimension in the database using the Analysis
Manager interface. Then I used the following code segment:

For Each dsoDB In dsoServer.MDStores
Debug.Print "DATABASE: " & dsoDB.Name & " - " & _
For Each dsoDim In dsoDB.Dimensions
Debug.Print " Dimension: " & dsoDim.Name
Debug.Print " From: " & dsoDim.FromClause
Debug.Print " Join: " & dsoDim.JoinClause
For Each dsoLev In dsoDim.Levels
Debug.Print " Level: " & dsoLev.Name
Debug.Print " CSize: " & dsoLev.ColumnSize
Debug.Print " CType: " & dsoLev.ColumnType
Debug.Print " ESize: " & dsoLev.EstimatedSize
Debug.Print " MKey: " & dsoLev.MemberKeyColumn

to extract the following information for my Dimension.

DATABASE: ProjectServer_Cube - OLAP Cube for ProjectServer database
Dimension: Project Manager
From: "dbo"."BSegE_Cube_................
Join: "dbo"."BSegE_Cube_.........
Level: (All)
CSize: 0
CType: 3
ESize: 1
MKey: All Project Manager
Level: Project Manager
CSize: 255
CType: 130
ESize: 28
MKey: dbo"."BSegE_Cube_..............

Using this information I wrote and executed the following code to
programmatically create my new Dimension.

' Create Products dimension and levels.
Set dsoDim = dsoDB.Dimensions.AddNew("Project Manager")
Set dsoDim.DataSource = dsoDS ' Dimension data source
dsoDim.FromClause = """dbo"".""BSegE_Cube_.............
dsoDim.JoinClause = (""dbo"".""BSegE_Cube............

' Add Brand Name level.
Set dsoLev = dsoDim.Levels.AddNew("All")
dsoLev.MemberKeyColumn = "All Project Manager"
dsoLev.ColumnSize = 255 ' Column data size in bytes
dsoLev.ColumnType = adInteger ' Column data type
dsoLev.EstimatedSize = 1 ' Distinct members in column

' Add Brand Name level.
Set dsoLev = dsoDim.Levels.AddNew("Project Manager")
dsoLev.MemberKeyColumn = ""dbo"".""BSegE_Cube_...............
dsoLev.ColumnSize = 255 ' Column data size in bytes
dsoLev.ColumnType = adWChar ' Column data type
dsoLev.EstimatedSize = 28 ' Distinct members in column

' Update and Process the Products dimension.

Unfortunately, when I Process the new Dimension the following VB error window
pops up.

Microsoft Visual Basic
Run-time error '-2147221425 (8004004f)':
Level has an invalid MemberKeyColumn

Additional debug work shows me that the problem is with the MemberKeyColumn
definition in the first (All) level. This puzzles me because, as you can see,
the value I am attempting to use is the value the new dimension wizard created
when I used the analysis manager interface.

Can anyone tell me what I am doing wrong?

Bob Segrest, PMP
(540) 937-5875