Posts Tagged .NET

Setting Up an ADOMD.NET Project

I made my first foray into ADOMD.NET today. ADOMD.NET is the technology used to connect to SQL Server Analysis Services. It seemed to work pretty well. Here is the key to the castle:

using Microsoft.AnalysisServices.AdomdClient;

The first step is to make sure you have a login for the SSAS client. My server uses integrated Windows security, so I had to tack on the “Integrated Security=SSPI;” modifier to the end of the connection string.

AdomdConnection conn = new AdomdConnection("Data Source=THE_SERVER;Initial Catalog=THE_DB;Integrated Security=SSPI;");

Next up, open the connection and set up an ADOMD command with which to submit your MDX query:

conn.Open();
AdomdCommand cmd = new AdomdCommand(@"SELECT [Measures].[Count] ON COLUMNS, [Geography].[Geo].[All] ON ROWS
FROM [DBNAME]", conn);

Use this command to fill a CellSet:

CellSet cs = cmd.ExecuteCellSet();

After this we can start slicing and dicing down to get the exact tuples we want. I recommend first creating a TupleCollection:

TupleCollection tuplesOnColumns = cs.Axes[0].Set.Tuples;

The cs.Axes[0].Set.Tuples refers to columns, whereas cs.Axes[1].Set.Tuples would refer to rows. I think this is a good stopping point, I”ll continue this later.

,

No Comments