1.连接
Public catalog As New ADOMD.Catalog
Dim strServer As String '服务器地址
Dim strCatalog As String
Dim strConn As String '连接串
Dim conn As New ADODB.Connection
![](/Images/OutliningIndicators/None.gif)
strServer = Session("Server") '得到服务器地址
strCatalog = Session("Catalog") '得到要连接的仓库名
![](/Images/OutliningIndicators/None.gif)
strConn = "Data Source=" & strServer & _
";Initial Catalog=" & strCatalog & _
";Provider=msolap;" '与数据仓库的连接串
![](/Images/OutliningIndicators/None.gif)
Try
conn.Open(strConn) '与OLAP服务器建立连接
Catch ex As Exception '出错
Session("error") = ex.ToString
Response.Redirect("SelectServer.aspx?ErrorNo=1")
End Try2.操作多维数据集及其维度
catalog.ActiveConnection = conn '将建立的连接赋给Catalog对象
'列出数据仓库中所有的多维数据集
Me.lstCubedef.Items().Clear()
Dim j As Integer
For j = 0 To catalog.CubeDefs().Count - 1
Me.lstCubedef.Items().Add(catalog.CubeDefs(j).Name)
Next
'也可以写为
'Dim cub As ADOMD.CubeDef
'For Each cub In catalog.CubeDefs
' Me.lstCubedef.Items().Add(cub.Name)
'Next
'列出多维数据集Sales的所有维度名
For i = 0 To catalog.CubeDefs["Sales"]._
Dimensions().Count - 1
Me.lstD.Items().Add(catalog.CubeDefs(CubeIndex)._
Dimensions(i).Name.ToString)
Next
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
'列出数据仓库中所有的多维数据集
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)