Листинг 1
Private Sub Command1_Click()
Dim Nod, Nod1 As Node, i, j, k, l As Integer
Dim Cat As New ADOMD.Catalog
Dim Cnn As New ADODB.Connection
Cnn.ConnectionString = "Provider=MSOLAP.2;Persist Security Info=True;”_
+”User ID=sa;Data Source=MAINDESK;Initial Catalog=NorthWind_OLAP"
Cnn.Open
Set Cat.ActiveConnection = Cnn
If Cat.CubeDefs.Count > 0 Then
Set Nod = TreeView1.Nodes.Add(, , "Catalog", "Catalog")
For i = 0 To Cat.CubeDefs.Count - 1
Set Nod1 = TreeView1.Nodes.Add("Catalog", tvwChild, _
Cat.CubeDefs(i).Name, Cat.CubeDefs(i).Name)
For j = 0 To Cat.CubeDefs(i).Dimensions.Count - 1
Set Nod1 = TreeView1.Nodes.Add(Cat.CubeDefs(i).Name, tvwChild, _
Cat.CubeDefs(i).Dimensions(j).UniqueName, _
Cat.CubeDefs(i).Dimensions(j).UniqueName)
For k = 0 To (Cat.CubeDefs(i).Dimensions(j).Hierarchies.Count - 1)
For l = 0 To _
(Cat.CubeDefs(i).Dimensions(j).Hierarchies(k).Levels.Count - 1)
Set Nod1 = _
TreeView1.Nodes.Add(Cat.CubeDefs(i).Dimensions(j).UniqueName,_
tvwChild, _
Cat.CubeDefs(i).Dimensions(j).Hierarchies(k).Levels(l).UniqueName,_
Cat.CubeDefs(i).Dimensions(j).Hierarchies(k).Levels(l).UniqueName)
Next l
Next k
Next j
Next i
Command1.Enabled = False
End If
End Sub