C# Adomd Connection Analysis Service View Cube
Posted WesChan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章
有没有人将 ADOMD.NET 与 WPF DataGrid 一起使用?
SSAS 2014 + ADOMD.Net 上的 1 小时超时 - 但没有设置为一小时的超时
ADOMD.net 和 Analysis Services OLE DB Provider 之间的差异(尤其是关于身份验证)