首页 > 代码库 > C# Adomd Connection Analysis Service View Cube
C# Adomd Connection Analysis Service View Cube
首先需要先引用 C:\Program Files\Microsoft.NET\ADOMD.NET\100\Microsoft.AnalysisServices.AdomdClient.dll
C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.AnalysisServices.DLL
参照来源为MSDN:http://gallery.technet.microsoft.com/scriptcenter/6901ede5-5d59-4b1f-8f1b-df3c8e645048#content
-------------------------------------------------------------------------------------------------------------------------------------
String ConnStr;
C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.AnalysisServices.DLL
参照来源为MSDN:http://gallery.technet.microsoft.com/scriptcenter/6901ede5-5d59-4b1f-8f1b-df3c8e645048#content
-------------------------------------------------------------------------------------------------------------------------------------
using Microsoft.AnalysisServices;
using Microsoft.AnalysisServices.Hosting;
String ConnStr;
String OLAPServerName;
String OLAPDB;
String OLAPCube;
OLAPServerName = "HZSV008";
OLAPDB = "TajimaSalesSubject";
OLAPCube = "销售主题分析模型";
ConnStr = "Provider=MSOLAP;Data Source=" + OLAPServerName + ";";
//Initial Catalog=Adventure Works DW 2008R2;";
Server OLAPServer = new Server();
OLAPServer.Connect(ConnStr);
Console.WriteLine("ServerName : " + OLAPServerName);
// Database
foreach (Database OLAPDatabase in OLAPServer.Databases)
{
if (OLAPDB == "" || OLAPDatabase.Name.ToString() == OLAPDB)
{
Console.WriteLine("DatabaseName : " + OLAPDatabase.Name);
// Cube
foreach (Cube OLAPCubex in OLAPDatabase.Cubes)
{
if (OLAPCube == "" || OLAPCubex.Name == OLAPCube)
{
Console.WriteLine("CubeName : " + OLAPCubex.Name);
//Cube Dimension
foreach (CubeDimension OLAPDimension in OLAPCubex.Dimensions)
{
Console.WriteLine("DimensionName : " + OLAPDimension.Name);
Console.WriteLine(" Attributes : ");
//Dimension Attribute
foreach (CubeAttribute OLAPDimAttribute in OLAPDimension.Attributes)
{
Console.WriteLine(" " + OLAPDimAttribute.Attribute.Name);
}
Console.WriteLine(" Hierarchy : ");
//Dimension Hierarchy
foreach (CubeHierarchy OLAPDimHierarchy in OLAPDimension.Hierarchies)
{
Console.WriteLine(" " + OLAPDimHierarchy.Hierarchy.Name);
//Dimension Hierarchy Level
foreach (Level OLAPDimHierachyLevel in OLAPDimHierarchy.Hierarchy.Levels)
{
Console.WriteLine(" " + OLAPDimHierachyLevel.Name);
}
}
//Measure Group
foreach (MeasureGroup OLAPMeasureGroup in OLAPCubex.MeasureGroups)
{
Console.WriteLine("Measure Group:" + OLAPMeasureGroup.Name);
Console.WriteLine("Measures:");
// Measures
foreach (Measure OLAPMeasure in OLAPMeasureGroup.Measures)
{
Console.WriteLine(" " + OLAPMeasure.Name);
}
Console.WriteLine("Measure Group Dimension:");
// Measure Group Dimension
foreach (MeasureGroupDimension OLAPMeasureGroupDimension in OLAPMeasureGroup.Dimensions)
{
Console.WriteLine(" " + OLAPMeasureGroupDimension.CubeDimension.Name);
}
Console.WriteLine("Partition:");
//Partitions
foreach (Partition OLAPPartition in OLAPMeasureGroup.Partitions)
{
Console.WriteLine(" " + OLAPPartition.Name);
}
}
}
}
}
}
}
Console.ReadKey();
C# Adomd Connection Analysis Service View Cube
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。