Imports Microsoft.AnalysisServices.AdomdClient
Imports System.Data
Imports Microsoft.AnalysisServices.AdomdClient.Dimension
Imports Microsoft.AnalysisServices.AdomdClient.CubeDef
Imports System.Object
Imports System.Diagnostics.Debug
Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As AdomdConnection
Dim str As String
str = "Data
Source=evenapp\evenapp;Catalog=Adventure Works DW; Integrated
Security=SSPI"
con = New AdomdConnection(str)
con.Open()
retrivecubesanddimensions()
con.close()
End Sub
Public Function retrivecubesanddimensions()
Dim cube As CubeDef
Dim dime As Dimension
Dim result As System.Text.StringBuilder
result = New System.Text.StringBuilder
For Each cube In con.Cubes
If cube.Name.StartsWith("A") Then
Console.WriteLine(cube.Name)
End If
Next cube
For Each dime In cube.Dimensions
Console.WriteLine(dime.Name)
Next dime
Return result.ToString
End Function
End Class
it doesn't work out for me i think there is a connection problem to the
database.And i couldn't able to create an instance of class
Cubedef.When i try to create it using cube = new cubedef it gives me ab
error "microsoft.AnalysisSerivces.AdomdClient.Cubedef" has no
constructors,i dont understand wat is this.

how to access a cube and its dimensions in a cube
James Xiao
So what can I do when I want to know get information on all cubes, not just those who have been successfully processed the 2000 OLE interface provided that info, but it looks like this one doesn't.
MrCrool
hello,
from the description above, it is not completely clear what the issue is. You state that connection fails. If that is the case, could you please provide more information as to what exception is thown by connection.Open() [with inner exception details if available]
If connection succeeds (which the second reply seems to indicate -- since opening conneciton with exactly the same connection string, definitelly succeeds because you are able to execute a command and get back results....), then what exectly is the problem
In general, to enumerate cubes and dimensions i'd expect something like this to work:
Dim cube As CubeDef Dim dimension As Dimension For Each cube In con.CubesConsole.WriteLine(cube.Name)
For Each dimension In cube.DimensionsConsole.WriteLine(dimension.Name)
Next dimension Next cubeAs to the error about CubeDef constructor: you should not need to create new CubeDef objects, you normally get the cube you need from the connection.Cubes collection.
hope this helps,
sqsAndres
So how do I get info equivalent to the MDStores...CubeState, SubClassType,OlapMode, EstimatedSize, Partition information, IsValid
I can't place this information within the AdomdConnection interface.
HLdeveloper
It seems that your connection string may be wrong. You are missing the provider (Provider=msolap) and maybe also your data source doesn't point to a host (Data Source=computerName\instanceName). If the database is on the same computer you should use Data Source=localhost\instanceName .
Try this sample code:
Dim strConn As String = "Provider=msolap; Data Source=localhost; Initial Catalog=Adventure Works DW;"
Dim dbConn As New AdomdConnection(strConn)
dbConn.Open()
Dim cube As CubeDef
For Each cube In dbConn.Cubes
Console.WriteLine(cube.Name)
Next
fshey
Hello Mary,
I am having a similar problem. I am attempting to get info on the cubes on my my local instance using SMO AdomdConnection.Cubes. My connection string is :
"Provider=msolap;Data Source=localhost\SS2005;Integrated Security=SSPI;Initial Catalog=Adventure Works DW"
I am able to connect, but I am always getting a zero cube count for the sample database, which should give me two cubes. The cubes in Adventure Works DW currently do not process without errors. Should I expect them to turn up in the list if and when they can be processed without error
John.
Martin Mason
Vitek Karas
the code that worked out for me is:
Dim con as AdomdConnection
Dim cmd as AdomdCommand
Dim str as String
Dim reader as System.xml.xmlreader
str = "Data Source=evenapp\evenapp;Catalog=Adventure Works DW; Integrated Security=SSPI"
con = New AdomdConnection(str)
cmd = New AdomdCommand
con.Open()
cmd = con.CreateCommand()
cmd.CommandText = "SELECT [Employee].[Gender].[Gender].Members on 0,{[Customer].[Customer].[Aaron A. Allen],[Customer].[Customer].[Abigail Clark]} on 1 FROM [Adventure Works] "
reader = cmd.ExecuteXmlReader
Response.Write(reader.ReadOuterXml())
This code gives me the whole database which i dont want, i want only the names of the cubes in the AdventureWorks database and the dimensions of the cubes.
Ram Kinkar Pandey
hello John,
For Adomd.Net you have to have cubes processed to get them from AdomdConnection.Cubes. Adomd.Net is basically intended for clients to browse, execute queries.
Perhaps you should consider using AMO (Microsoft.AnalysisServices.dll) as it's functionality might suit you better (i'm not completely clear on what you are trying to do, i'm just guessing). AMO is intended for management tasks. It should allow you to get access to non-processed cubes, their properties, etc. In AMO you create a Server object, and connect. [you can find more information on AMO: http://msdn2.microsoft.com/en-us/library/ms124924(SQL.90).aspx]
hope this helps,