SSAS Series-"08" Multidimensional data (program presentation Cube)

Source: Internet
Author: User

Original: SSAS Series-"08" Multidimensional data (program shows Cube)

1. Reference dll?

After installing the MS SQL Server installation, you find that the Microsoft.AnalysisServices.AdomdClient namespace was not found in the new project "Add Reference", do you know what the situation is? Had to add the DLL, under "C:\Program files\microsoft.net\adomd.net\100\microsoft.analysisservices.adomdclient.dll" found the file, The last modification time for this file is March 30, 2009, 534KB.

Figure AdomdClient.dll the disk path

2. Connection string?

I think this piece and the ADO is not too big difference, here I use the connection string is: Provider=sqlncli10.1;data source=localhost;integrated security=sspi;initial CATALOG=BPDW; , the string can be found in the data source designer, so there is no need to remember, and you can find it.

Figure Connection String

3, the first program

Code
  string Returncommandusingcellset ()
{
//Createa new string builder toStore the results
System.Text. StringBuilder result=new System.Text. StringBuilder ();
//Connect toThe local server
using (Adomdconnection conn=new Adomdconnection ("Provider=SQLNCLI10.1;D ata Source=localhost;integrated Security=sspi;initial Catalog=BPDW; "))
{
Conn.Open();
//Createa command, using this connection
Adomdcommand cmd=Conn. CreateCommand ();
Cmd.commandtext= @"Select {[Measures].[Oil proved reserves]} oncolumns, {[Dim Time].[year].&[ +]} onrows from [BPDW]where [Dim Geography].[Country name].&[Total Asia Pacific]&[ China]";
//Executethe query, returning a Cellset
CellSet CS=cmd. Executecellset ();
//Output thecolumnCaptions fromThe first axis
//Note that thisprocedureassumes a Singlememberexistspercolumn.
Result. Append ("\ t");
Tuplecollection Tuplesoncolumns=cs. Axes[0].Set. tuples;
foreach (Microsoft.AnalysisServices.AdomdClient.Tuplecolumn inchtuplesoncolumns)
{
Result. Append (column. Members[0]. Caption+"\ t");
}
Result. Appendline ();
//Output the row captions fromThe second axis andcell Data
//Note that thisprocedureassumes a-dimensional Cellset
Tuplecollection tuplesonrows=cs. Axes[1].Set. tuples;
for (intRow= 0; row<tuplesonrows.Count; row++)
{
Result. Append (Tuplesonrows[Row]. Members[0]. Caption+"\ t");
for (intCol= 0; Col<Tuplesoncolumns.Count; Col++)
{
Result. Append (CS. Cells[col, Row]. FormattedValue+"\ t");
}
Result. Appendline ();
}
Conn.Close();
returnresult. ToString ();
} //Using Connection
}

SSAS Series-"08" Multidimensional data (program presentation Cube)

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.