I am trying to retrieve the Cube names from Analysis Manager 2000 by using DSO objects in VS2005.NET C# 2.0 ( framework 2.0)
The code is something like that.
DSO.Server srv = new DSO.Server();
srv.Connect("localhost");
after that i do not what to do in order to get the cube names from AM2000.
when i do the following
srv.MDStore.Count
i can get the number of the cubes but i cant get the names.
I tried to use the following method but did not work out.
srv.MDStore.Item(object vntIndexKey)
May be i do not know how to use the above method to get the cube names.
for(int i = 0; i < srv.MDStore.Count; i++)
combobox1.Item.Add(srv.MDStore.Item(i).ToString());
the above code does not add the cube names into combobox, either. (
Please somebody help me with this problem.
I need to get the cube names from the AM2000 to let the user choose what cube he/she wants to work with!?
thanks in advance
best regards
Tunc OVACIK
DSO is the wrong API to use for something ordinary users need to run. DSO is the admin API and will only work for OLAP Administrators.
You should use the ADOMD or ADOMD.NET api, the MDX Sample app has code that does this using the older ADOMD API.
There is a sample in BOL for using ADOMD.NET to get a list of cubes which I have copied out below, the original page is available here
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/adodw9/html/0183dcdc-f2ea-4246-ad00-6e8ccc9d8217.htm
Code Snippet
private string RetrieveCubesAndDimensions()
{
System.Text.StringBuilder result = new System.Text.StringBuilder();
//Connect to the local server
using (AdomdConnection conn = new AdomdConnection("Data Source=localhost;"))
{
conn.Open();
//Loop through every cube
foreach (CubeDef cube in conn.Cubes)
{
//Skip hidden cubes.
if (cube.Name.StartsWith("$"))
continue;
//Write the cube name
result.AppendLine(cube.Name);
//Write out all dimensions, indented by a tab.
foreach (Dimension dim in cube.Dimensions)
{
result.Append("\t");
result.AppendLine(dim.Name);
}
}
//Close the connection
conn.Close();
}
//Return the results
return result.ToString();
}
Hello again,
I have succedded to get the cube names from AM2000 by using DSO API. To do this job with DSO API is very easy.
For further information for the others who may need it I will give the sample code.
string[] cubeNames;
DSO.Server dsoServer = new DSO.Server();
dsoServer.Connect("localhost");
// Count will return the number of cubes on AM2000
cubeNames = new string[dsoServer.MDStore.Count];
int i = 0;
foreach( DSO.MDStore cube in dsoServer.MDStore)
{
cubeNames = cube.Name;
i++;
}
Before going through the code you should add the relevant .dll file into your project from the "Add Reference" menu.
Actually it is possible to get the cube names by using ADOMD classes as well as Darren said. I thank you for your help which was really usefull. So, the next step for me is to go through the cube and get the neccesarry data I need to make report for the user.
thanks for everything
Tunc OVACIK
|||The DSO code will only work for administrators, you can run it because you are an admin, normal users will not be able to run it. Hence the reason I suggested using Adomd.
No comments:
Post a Comment