C # ADOMD Connection analysis Service View Cube

Source: Internet
Author: User

You first need to refer to C:\Program Files\microsoft.net\adomd.net\100\microsoft.analysisservices.adomdclient.dll
C:\Program Files\Microsoft SQL Server\100\sdk\assemblies\microsoft.analysisservices.dll
Reference source is 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;      &N Bsp     String olapcube;              Olapservername = "HZSV008";  &nbs P         olapdb = "Tajimasalessubject";            Olapcube = "Sales-themed analysis model";               CONNSTR = "Provider=msolap;data source=" + Olapservername + ";";            //initial catalog=adventure Works DW 2008R2; ";               Server olapserver = new server ();            Olapserver.connect (CONNSTR);             Console.WriteLine ("ServerName:" + OL Apservername);            //database             foreach (Database olapdatabase in olapserver.databases)   &N Bsp         {                 if (olapdb = = "" | | OLAPDatabase.Name.ToString () = olapdb)                 {      &NBSP ;             Console.WriteLine ("DatabaseName:" + olapdatabase.name);     &NB Sp              //cube                 &NBS P   foreach (Cube olapcubex in Olapdatabase.cubes)                     {                        if (Olapcube = = "" | | Olapcubex.name = = olapcube)                         {  &NB Sp         &NBSp               Console.WriteLine ("CubeName:" + olapcubex.name);     &NB Sp                      //cube dimension       &N Bsp                     foreach (Cubedimension olapdimension in Olapcubex.di mensions)                             {                                Console.WriteLine ("Dimen Sionname: "+ olapdimension.name);                        &NB Sp       Console.WriteLine ("   attributes:");             &NBS P                  //dimension attribute         &NBS P &nbsp                     foreach (CubeAttribute olapdimattribute in Olapdimen Sion. Attributes)                                 {                                  nbsp Console.WriteLine ("         " + OLAPDimAttribute.Attribute.Name);        &N Bsp                      }           &NB Sp                     Console.WriteLine ("   hierarchy:"); &nbs p;                               //dimens Ion hierarchy                             &NBSP   foreach (Cubehierarchy olapdimhierarchy in olapdimension.hierarchies)             &NB Sp                   {                &N Bsp                   Console.WriteLine ("         " + O LAPDimHierarchy.Hierarchy.Name);                                    //dimension Hierarchy level             &NBS P                       foreach (Level olapdimhierachylevel in Olapdi MHierarchy.Hierarchy.Levels)                           &NB Sp         {                          &N Bsp &nBsp           Console.WriteLine ("               " + olapdimh Ierachylevel.name);                            &NBSP ;      }                            &N Bsp  }                           /  &NBS P  //measure group                           &NB Sp     foreach (MeasureGroup olapmeasuregroup in olapcubex.measuregroups)                                 {              & nbsp                     Console.WriteLine ("Measure Group:" + OlapmeasuregrouP.name);                                &N Bsp   Console.WriteLine ("Measures:");                /      & nbsp            //measures                                     foreach (Measure olapmeasure in Olapmeasuregroup.measures) & nbsp                          /        {&N Bsp                          ,         &NB Sp   Console.WriteLine ("         " + olapmeasure.name);          &NBS P                        }                                     Console.WriteLine ("Measu Re Group Dimension: ");                           &NB Sp        //Measure Group dimension                                     foreach (Measuregroupdimension olapmeasuregroupdimension i n olapmeasuregroup.dimensions)                           + nbsp         {                          &N Bsp             Console.WriteLine ("         " + Olapmeasuregroupdimens Ion. Cubedimension.name);                            &NBS P     }                           &NB Sp         Console.WriteLine ("Partition:");                                   //partitions           &NBSP ;                         foreach (Partition olappartition in OL apmeasuregroup.partitions)                           &NBSP ;         {                          &N Bsp             Console.WriteLine ("         " + olappartition.name); &n Bsp                          ,        }&N Bsp;&nBsp                              }  &NBS P                          }        &N Bsp              }                   &NB Sp }               }              }&NB sp;             Console.readkey (); 

C # ADOMD Connection analysis Service View Cube

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.