The following code needs to reference Microsoft.AnalysisServices.AdomdClient.dll: string asConnectionString = "Provider=MSOLAP.3;Data Source=localhost;Initial Catalog=Adventure Works DW"; AdomdConnection asConnection = new AdomdConnection(asConnectionString); try { asConnection.Open(); foreach (CubeDef cubeDef in asConnection.Cubes) { if (cubeDef.Properties["CUBE_TYPE"].Value.Equals("CUBE")) { string commandText = @"SELECT { strtomember(@Value), strtomember(@Goal), strtomember(@Status), strtomember(@Trend) } ON COLUMNS FROM [" + cubeDef.Name + "]"; AdomdCommand command = new AdomdCommand(commandText, this.asConnection); foreach (Kpi kpi in cubeDef.Kpis) { command.Parameters.Clear(); command.Parameters.Add(new AdomdParameter("Value", kpi.Properties["KPI_VALUE"].Value)); command.Parameters.Add(new AdomdParameter("Goal", kpi.Properties["KPI_GOAL"].Value)); command.Parameters.Add(new AdomdParameter("Status", kpi.Properties["KPI_STATUS"].Value)); command.Parameters.Add(new AdomdParameter("Trend", kpi.Properties["KPI_TREND"].Value)); CellSet cellset = command.ExecuteCellSet(); Debug.WriteLine("KPI Name:" + kpi.Name); Debug.WriteLine("Value:" + cellset.Cells[0].FormattedValue); Debug.WriteLine("Goal:" + cellset.Cells[1].FormattedValue); Debug.WriteLine("Status:" + cellset.Cells[2].FormattedValue); Debug.WriteLine("Trend:" + cellset.Cells[3].FormattedValue); } } } } finally { asConnection.Close(); } |