Solved

'Microsoft.AnalysisServices.AdomdClient.Dimension' does not contain a definition

Posted on 2013-11-01
2
994 Views
Last Modified: 2013-11-04
I am getting the following errors:
'Microsoft.AnalysisServices.AdomdClient.Dimension' does not contain a definition for 'ID'
and no extension method 'ID' accepting a first argument of type 'Microsoft.AnalysisServices.AdomdClient.Dimension'
could be found (are you missing a using directive or an assembly reference?)      
Error Line 451      66

'Microsoft.AnalysisServices.AdomdClient.Dimension' does not contain a definition for 'KeyAttribute'
and no extension method 'KeyAttribute' accepting a first argument of type 'Microsoft.AnalysisServices.AdomdClient.Dimension'
could be found (are you missing a using directive or an assembly reference?)      
Error Line 455      66      

The code below is where the error is coming from:
private static void GenerateCube(Microsoft.AnalysisServices.Cube objCube, Dimension objDimension, Microsoft.AnalysisServices.MeasureGroup objMeasureGroup, string strFactTableName, string strTableKey)
        {
            try
            {
                Microsoft.AnalysisServices.CubeDimension objCubeDim = new Microsoft.AnalysisServices.CubeDimension();
                Microsoft.AnalysisServices.RegularMeasureGroupDimension objRegMGDim = new Microsoft.AnalysisServices.RegularMeasureGroupDimension();
                Microsoft.AnalysisServices.MeasureGroupAttribute objMGA = new Microsoft.AnalysisServices.MeasureGroupAttribute();
                //Add Dimension to the Cube
                objCubeDim = objCube.Dimensions.Add(objDimension.ID);// Error Here Line 451
                //Use Regular Relationship Between Dimension and FactTable Measure Group
                objRegMGDim = objMeasureGroup.Dimensions.Add(objCubeDim.ID);
                //Link TableKey in DimensionTable with TableKey in FactTable Measure Group
                objMGA = objRegMGDim.Attributes.Add(objDimension.KeyAttribute.ID);// Error Here Line 455
                objMGA.Type = Microsoft.AnalysisServices.MeasureGroupAttributeType.Granularity;
                objMGA.KeyColumns.Add(strFactTableName, strTableKey, OleDbType.Integer);
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Creating the Cube, MeasureGroup, Measure, and Partition Objects - GenerateCube. Error Message -> " + ex.Message);
            }
        }		

Open in new window

Thanks in advance for any help given
For clarity below is the complete code:
using System;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;
using System.Data.Common;
using System.Web.Configuration;
using System.Diagnostics;
using System.Text;
using System.IO;
using System.Collections;
using System.Xml;
using System.Net;
using System.Text.RegularExpressions;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.ComponentModel;
using System.Drawing;
using System.Web.SessionState;

//using Microsoft.SqlServer.Management.Common;
//using Microsoft.SqlServer.Management.Smo;
//using Microsoft.SqlServer.Management.Sdk.Sfc;
//using Microsoft.AnalysisServices;
//using Microsoft.AnalysisServices.AdomdServer;
//using Microsoft.AnalysisServices.AdomdClient;
//using Microsoft.AnalysisServices.Server;
using Microsoft.AnalysisServices.AdomdClient;
public partial class aaaMisc0 : System.Web.UI.Page
{
public string page_Renamed;
    public int j;
    public int i;
    public string connectionString;
    protected string[] strArrayDB33 = new string[31];
    protected string[] strArrayDetail33 = new string[31];
    protected string[] strArrayTable33 = new string[31];
    public int intstrDetail22;
    public int intstrDetail55;
    public string strSession2;
    public string DataBaseLabelappTest;
    public string TableLabelappTest;
    public string strIntappTest;
    protected int intDetail22;
    public string IsConnectionInfoSetappTest;
    public string ProviderLabelappTest;
    public string detailsLabel2appTest;
    public string detailsLabelappTest;
    public string strDB22;
    public string strDBT22;
    public ArrayList ParameterArray = new ArrayList();
    public static DataTable Table = new DataTable();
    public string odbName;
    public string lblXMLFile;
	public DropDownList ddl;
public aaaMisc0()
    {
        Page.Init += new System.EventHandler(Page_Init);
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        if (Page.User.Identity.IsAuthenticated)
        {
            Page.ViewStateUserKey = Page.Session.SessionID;
        }
        InitializeComponent();
		//BuildDynamicDropDown();
    }// End Page_Init
protected void Page_Load(object sender, System.EventArgs e)
    {
        Session["strArrayPageName"] = "aaaMisc";Session["IsConnectionInfoSet"] = false;
        HttpContext.Current.Response.Write(MyAppCSDefault0.divStart2);
        try
        {
            if (Session["strConnection"] == null){DataServer.Text = "<font color='red'>" + "!-Connected!!" + "</font>";}else{DataServer.Text = "Connected!!";}
			if (!IsPostBack)
            {
                HttpContext.Current.Response.Write("<span id='spanpost1' style='position:absolute;top:-12px;'>" + "!IsPB:" + "</span>");
                intstrDetail55 = intstrDetail55 + 1;Session["strPage"] = intstrDetail55;
				if (Session["strConnection"] != null)
                {              
					BindData8();BindData9();
					//<!-- Start Page Content -->
					
                    //<!-- End Page Content -->
                    //CreateTemplatedGridView();
                }
				//Sprocs.DataBind();//UpdateParameterDisplay();
                //<!-- Start Page Content -->
                
                //<!-- End Page Content -->
            }// End !IsPostBack
            else
            {
                HttpContext.Current.Response.Write("<span id='spanpost1' style='position:absolute;top:-12px;'>" + "IsPB:" + "</span>");
                intstrDetail55 = intstrDetail55 + 1;Session["strPage"] = intstrDetail55;
                if (Session["strConnection"] != null)
                {
                    //<!-- Start Page Content -->
					
                    //<!-- End Page Content -->
                    //CreateTemplatedGridView();
                }
            }// End else
        } // End try
        catch (Exception ex)
        {
            errorLabel4.Text = "<font color='red'>" + "err:111E:PL:" + "</font>" + ex.ToString();
        } // End catch
        if (Page.IsPostBack && System.Convert.ToBoolean(Session["IsConnectionInfoSet"]) == true)
        {
            //<!-- Start Page Content -->
			
            //<!-- End Page Content -->
            //CreateTemplatedGridView();
        }
        HttpContext.Current.Response.Write(MyAppCSDefault0.divEnd);
    }// End Page_Load
private void InitializeComponent()
    {
	
    }
protected void Logout_Click(object sender, System.EventArgs e)
    {
        Session["strConnection"] = null;Session["IsConnectionInfoSet"] = false;
    } // End Logout_Click
    protected void LoginButton_Click(object sender, System.EventArgs e)
    {
        Response.Redirect("../../modules/create_cams_managers/connect0.aspx?MainMenuId=0&SubMenuId=0&db22=AdminDB2&dt22=AdminTable2&intDetail22=0&strD22=False&page=0");
    } // End LoginButton_Click
public void BindData8()
    {
    try
		{
			strDB22 = Request["db22"];strDBT22 = Request["dt22"];
            string connectionString = System.Convert.ToString(Session["strConnection"]) + " Initial Catalog=" + strDB22 + ";";
            intstrDetail55 = System.Convert.ToInt32(Session["strPage"]);
            if (intstrDetail55 >= 0){}else{Session["strPage"] = 0;}
			
			string server_tb = (string)Session["Server"];string user_tb = (string)Session["UserName"];string pswrd_tb = (string)Session["Password"];string database_tb = (string)Session["DatabaseSelected"];string table_tb = (string)Session["TableSelected"];
			string connstr = "@" + Session["strConnection"] + "Initial Catalog=" + strDB22 + ";";string[] str1 = connstr.Split(';');
            server_tb = str1[0].Split('=')[1];user_tb = str1[1].Split('=')[1];pswrd_tb = str1[2].Split('=')[1];database_tb = str1[3].Split('=')[1];table_tb = strDBT22;
			Session["Server"] = server_tb;Session["UserName"] = user_tb;Session["Password"] = pswrd_tb;Session["DatabaseSelected"] = database_tb;Session["TableSelected"] = table_tb;
        }
		catch (Exception ex)
        {
            errorLabel4.Text = "<font color='red'>" + "err:150E:BD8:" + "</font>" + ex.ToString();
        } // End catch
	}// End BindData8	
public void BindData9()
    {
    try
		{
			string server_tb = (string)Session["Server"];string user_tb = (string)Session["UserName"];string pswrd_tb = (string)Session["Password"];string database_tb = (string)Session["DatabaseSelected"];string table_tb = (string)Session["TableSelected"];
			string connectionString = System.Convert.ToString(Session["strConnection"]);
			lblTable.Text = "<font color='Silver'>" + "Ln:159T:BD9:" + connectionString + "#" + "</font>" + "<font color='green'>" + "&nbsp;&nbsp;&nbsp;&nbsp;tbl:" + "</font>" + "<font color='Silver'>" + table_tb + "#" + "</font>";
			errorLabel4.Text = "<font color='red'>" + "msg:160T:BD9:" + "</font>" + "message:=>ex.ToString()";				
            HttpContext.Current.Response.Write("<br/><br/>&nbsp;&nbsp;Yes:");
            //<!-- Start Page Content -->
            HttpContext.Current.Response.Write("Cube creation process started.");
            HttpContext.Current.Response.Write("");
                string strDBServerName = "LocalHost";
                string strProviderName = "msolap";
                string strFactTableName = "FactResellerSales";
                string strDBName = "AdventureWorksDW2008";
                string strCubeDBName = "OLAPDB";
                string strCubeDataSourceName = "OLAPDS";
                string strCubeDataSourceViewName = "OLAPDSView";
                int intDimensionTableCount = 6;
                string[,] strTableNamesAndKeys = { { "DimCurrency", "CurrencyKey", "FactResellerSales", "CurrencyKey" },
                                                   { "DimEmployee", "EmployeeKey", "FactResellerSales", "EmployeeKey" },
                                                   { "DimProduct", "ProductKey", "FactResellerSales", "ProductKey" },
                                                   { "DimPromotion", "PromotionKey", "FactResellerSales", "PromotionKey" },
                                                   { "DimReseller", "ResellerKey", "FactResellerSales", "ResellerKey" },
                                                   { "DimSalesTerritory", "SalesTerritoryKey", "FactResellerSales", "SalesTerritoryKey" },
                                                 };
                Microsoft.AnalysisServices.Server objServer = new Microsoft.AnalysisServices.Server();
                Microsoft.AnalysisServices.Database objDatabase = new Microsoft.AnalysisServices.Database();
                Microsoft.AnalysisServices.RelationalDataSource objDataSource = new Microsoft.AnalysisServices.RelationalDataSource();
                Microsoft.AnalysisServices.DataSourceView objDataSourceView = new Microsoft.AnalysisServices.DataSourceView();
                DataSet objDataSet = new DataSet();
                Dimension[] objDimensions = new Dimension[intDimensionTableCount];
                //Connecting to the Analysis Services.
                objServer = (Microsoft.AnalysisServices.Server)ConnectAnalysisServices(strDBServerName, strProviderName);
                //Creating a Database.
                objDatabase = (Microsoft.AnalysisServices.Database)CreateDatabase(objServer, strCubeDBName);
                //Creating a DataSource.
                objDataSource = (Microsoft.AnalysisServices.RelationalDataSource)CreateDataSource(objServer, objDatabase, strCubeDataSourceName, strDBServerName, strDBName);
                //Creating a DataSourceView.
                objDataSet = (DataSet)GenerateDWSchema(strDBServerName, strDBName, strFactTableName, strTableNamesAndKeys, intDimensionTableCount);
                objDataSourceView = (Microsoft.AnalysisServices.DataSourceView)CreateDataSourceView(objDatabase, objDataSource, objDataSet, strCubeDataSourceViewName);
                //Creating the Dimension, Attribute, Hierarchy, and MemberProperty Objects.                
                objDimensions = (Dimension[])CreateDimension(objDatabase, objDataSourceView, strTableNamesAndKeys, intDimensionTableCount);
                //Creating the Cube, MeasureGroup, Measure, and Partition Objects.
                CreateCube(objDatabase, objDataSourceView, objDataSource, objDimensions, strFactTableName, strTableNamesAndKeys, intDimensionTableCount);
                objDatabase.Process(Microsoft.AnalysisServices.ProcessType.ProcessFull);
                HttpContext.Current.Response.Write("Cube created successfully.");
			//<!-- End Page Content -->
			errorLabel4.Text = "<font color='red'>" + "msg:165T:BD9:" + "</font>" + "Olap Connection Ok";
		}
		catch (Exception ex)
        {
            errorLabel4.Text = "<font color='red'>" + "err:169E:BD9:" + "</font>" + ex.ToString();
        } // End catch
		HttpContext.Current.Response.Write("");
        HttpContext.Current.Response.Write("Press any key to exit.");
        Console.ReadLine();
	}// End BindData9
private static object ConnectAnalysisServices(string strDBServerName, string strProviderName)
        {       
        try
            {
                HttpContext.Current.Response.Write("Connecting to the Analysis Services ...");
                Microsoft.AnalysisServices.Server objServer = new Microsoft.AnalysisServices.Server();
                string strConnection = "Data Source=" + strDBServerName + ";Provider=" + strProviderName + ";";
                //Disconnect from current connection if it's currently connected.
                if (objServer.Connected)
                    objServer.Disconnect();
                else
                    objServer.Connect(strConnection);
                return objServer;
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Connecting to the Analysis Services. Error Message -> " + ex.Message);
                return null;
            }
        }
private static object CreateDatabase(Microsoft.AnalysisServices.Server objServer, string strCubeDBName)
        {
            try
            {
                HttpContext.Current.Response.Write("Creating a Database ...");
                Microsoft.AnalysisServices.Database objDatabase = new Microsoft.AnalysisServices.Database();
                //Add Database to the Analysis Services.
                objDatabase = objServer.Databases.Add(objServer.Databases.GetNewName(strCubeDBName));
                //Save Database to the Analysis Services.
                objDatabase.Update();                
                return objDatabase;
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Creating a Database. Error Message -> " + ex.Message);
                return null;
            }
        }
private static object CreateDataSource(Microsoft.AnalysisServices.Server objServer, Microsoft.AnalysisServices.Database objDatabase, string strCubeDataSourceName, string strDBServerName, string strDBName)
        {
            try
            {
                HttpContext.Current.Response.Write("Creating a DataSource ...");
                Microsoft.AnalysisServices.RelationalDataSource objDataSource = new Microsoft.AnalysisServices.RelationalDataSource();
                //Add Data Source to the Database.
                objDataSource = objDatabase.DataSources.Add(objServer.Databases.GetNewName(strCubeDataSourceName));
                //objDataSource.ConnectionString = "Provider=SQLOLEDB.1;Initial Catalog=AdventureWorksDW2008;Data Source=LocalHost;Integrated Security=True;";
                objDataSource.ConnectionString = "Provider=SQLNCLI.1; Data Source=" + strDBServerName + "; Initial Catalog=" + strDBName + "; Integrated Security=SSPI;";
                objDataSource.Update();

                return objDataSource;
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Creating a DataSource. Error Message -> " + ex.Message);
                return null;
            }
        }
private static object GenerateDWSchema(string strDBServerName, string strDBName, string strFactTableName, string[,] strTableNamesAndKeys, int intDimensionTableCount)
        {
            try
            {
                HttpContext.Current.Response.Write("Creating a DataSourceView ...");
                //Create the connection string.
                string conxString = "Data Source=" + strDBServerName + "; Initial Catalog=" + strDBName + "; Integrated Security=True;";
                //Create the SqlConnection.
                SqlConnection objConnection = new SqlConnection(conxString);
                DataSet objDataSet = new DataSet();
                //Add FactTable in DataSet.
                objDataSet = (DataSet)FillDataSet(objConnection, objDataSet, strFactTableName);
                //Add table in DataSet and Relation between them.
                for (int i = 0; i < intDimensionTableCount; i++)
                {
                    //Retrieve table's schema and assign the table's schema to the DataSet.
                    //Add primary key to the schema according to the primary key in the tables.
                    objDataSet = (DataSet)FillDataSet(objConnection, objDataSet, strTableNamesAndKeys[i, 0]);
                    objDataSet = (DataSet)AddDataTableRelation(objDataSet, strTableNamesAndKeys[i, 0], strTableNamesAndKeys[i, 1], strTableNamesAndKeys[i, 2], strTableNamesAndKeys[i, 3]);
                }
                return objDataSet;
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Creating a DataSourceView - GenerateDWSchema. Error Message -> " + ex.Message);
                return null;
            }
        }
private static object FillDataSet(SqlConnection objConnection, DataSet objDataSet, string strTableName)
        {
            try
            {
                string strCommand = "Select * from " + strTableName;
                SqlDataAdapter objEmpData = new SqlDataAdapter(strCommand, objConnection);
                objEmpData.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                objEmpData.FillSchema(objDataSet, SchemaType.Source, strTableName);
                return objDataSet;
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Creating a DataSourceView - FillDataSet. Error Message -> " + ex.Message);
                return null;
            }
        }
private static object AddDataTableRelation(DataSet objDataSet, string strParentTableName, string strParentTableKey, string strChildTableName, string strChildTableKey)
        {
            try
            {
                objDataSet.Relations.Add(strChildTableName + "_" + strParentTableName + "_FK", objDataSet.Tables[strParentTableName].Columns[strParentTableKey], objDataSet.Tables[strChildTableName].Columns[strChildTableKey]);
                return objDataSet;
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Creating a DataSourceView - AddDataTableRelation. Error Message -> " + ex.Message);
                return null;
            }
        }
private static object CreateDataSourceView(Microsoft.AnalysisServices.Database objDatabase, Microsoft.AnalysisServices.RelationalDataSource objDataSource, DataSet objDataSet, string strCubeDataSourceViewName)
        {
            try
            {
                Microsoft.AnalysisServices.DataSourceView objDataSourceView = new Microsoft.AnalysisServices.DataSourceView();
                //Add Data Source View to the Database.
                objDataSourceView = objDatabase.DataSourceViews.Add(objDatabase.DataSourceViews.GetNewName(strCubeDataSourceViewName));
                objDataSourceView.DataSourceID = objDataSource.ID;
                objDataSourceView.Schema = objDataSet;
                objDataSourceView.Update();
                return objDataSourceView;
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Creating a DataSourceView - CreateDataSourceView. Error Message -> " + ex.Message);
                return null;
            }
        }
private static object[] CreateDimension(Microsoft.AnalysisServices.Database objDatabase, Microsoft.AnalysisServices.DataSourceView objDataSourceView, string[,] strTableNamesAndKeys, int intDimensionTableCount)
        {
            try
            {
                HttpContext.Current.Response.Write("Creating the Dimension, Attribute, Hierarchy, and MemberProperty Objects ...");

                Dimension[] objDimensions = new Dimension[intDimensionTableCount];
                for (int i = 0; i < intDimensionTableCount; i++)
                {
                    objDimensions[i] = (Dimension)GenerateDimension(objDatabase, objDataSourceView, strTableNamesAndKeys[i, 0], strTableNamesAndKeys[i, 1]);
                }
                ////Add Hierarchy and Level
                //Hierarchy objHierarchy = objDimension.Hierarchies.Add("ProductByCategory");
                //objHierarchy.Levels.Add("Category").SourceAttributeID = objCatKeyAttribute.ID;
                //objHierarchy.Levels.Add("Product").SourceAttributeID = objProdKeyAttribute.ID;
                ////Add Member Property
                ////objProdKeyAttribute.AttributeRelationships.Add(objProdDescAttribute.ID);
                //objDimension.Update();
                return objDimensions;
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Creating the Dimension, Attribute, Hierarchy, and MemberProperty Objects. Error Message -> " + ex.Message);
                return null;
            }
        }
private static object GenerateDimension(Microsoft.AnalysisServices.Database objDatabase, Microsoft.AnalysisServices.DataSourceView objDataSourceView, string strTableName, string strTableKeyName)
        {
            try
            {
                Microsoft.AnalysisServices.Dimension objDimension = new Microsoft.AnalysisServices.Dimension();
                //Add Dimension to the Database
                objDimension = objDatabase.Dimensions.Add(strTableName);
                objDimension.Source = new Microsoft.AnalysisServices.DataSourceViewBinding(objDataSourceView.ID);
                Microsoft.AnalysisServices.DimensionAttributeCollection objDimensionAttributesColl = objDimension.Attributes;
                //Add Dimension Attributes
                Microsoft.AnalysisServices.DimensionAttribute objAttribute = objDimensionAttributesColl.Add(strTableKeyName);
                //Set Attribute usage and source
                objAttribute.Usage = Microsoft.AnalysisServices.AttributeUsage.Key;
                objAttribute.KeyColumns.Add(strTableName, strTableKeyName, OleDbType.Integer);
                objDimension.Update();
                return objDimension;
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Creating the Dimension, Attribute, Hierarchy, and MemberProperty Objects - GenerateDimension. Error Message -> " + ex.Message);
                return null;
            }
        }
private static void CreateCube(Microsoft.AnalysisServices.Database objDatabase, Microsoft.AnalysisServices.DataSourceView objDataSourceView, Microsoft.AnalysisServices.RelationalDataSource objDataSource, Dimension[] objDimensions, string strFactTableName, string[,] strTableNamesAndKeys, int intDimensionTableCount)
        {
            try
            {
                HttpContext.Current.Response.Write("Creating the Cube, MeasureGroup, Measure, and Partition Objects ...");
                Microsoft.AnalysisServices.Cube objCube = new Microsoft.AnalysisServices.Cube();
                Microsoft.AnalysisServices.Measure objSales = new Microsoft.AnalysisServices.Measure();
                Microsoft.AnalysisServices.Measure objQuantity = new Microsoft.AnalysisServices.Measure();
                Microsoft.AnalysisServices.MdxScript objTotal = new Microsoft.AnalysisServices.MdxScript();
                String strScript;
                Microsoft.AnalysisServices.Partition objPartition = new Microsoft.AnalysisServices.Partition();
                Microsoft.AnalysisServices.Command objCommand = new Microsoft.AnalysisServices.Command();
                //Add Cube to the Database and set Cube source to the Data Source View
                objCube = objDatabase.Cubes.Add("SampleCube");
                objCube.Source = new Microsoft.AnalysisServices.DataSourceViewBinding(objDataSourceView.ID);
                //Add Measure Group to the Cube
                //MeasureGroup objMeasureGroup = objCube.MeasureGroups.Add("FactSales");
                Microsoft.AnalysisServices.MeasureGroup objMeasureGroup = objCube.MeasureGroups.Add(strFactTableName);
                //Add Measure to the Measure Group and set Measure source
                objSales = objMeasureGroup.Measures.Add("Amount");
                objSales.Source = new Microsoft.AnalysisServices.DataItem(strFactTableName, "SalesAmount", OleDbType.Currency);
                objQuantity = objMeasureGroup.Measures.Add("Quantity");
                objQuantity.Source = new Microsoft.AnalysisServices.DataItem(strFactTableName, "OrderQuantity", OleDbType.Integer);
                ////Calculated Member Definition
                //strScript = "Calculated; Create Member CurrentCube.[Measures].[Total] As [Measures].[Quantity] * [Measures].[Amount]";
                ////Add Calculated Member
                //objTotal.Name = "Total Sales";
                //objCommand.Text = strScript;
                //objTotal.Commands.Add(objCommand);
                //objCube.MdxScripts.Add(objTotal);
                for (int i = 0; i < intDimensionTableCount; i++)
                {
                    GenerateCube(objCube, objDimensions[i], objMeasureGroup, strFactTableName, strTableNamesAndKeys[i, 3]);
                }
                objPartition = objMeasureGroup.Partitions.Add(strFactTableName);
                objPartition.Source = new Microsoft.AnalysisServices.TableBinding(objDataSource.ID, "dbo", strFactTableName);
                objPartition.ProcessingMode = Microsoft.AnalysisServices.ProcessingMode.Regular;
                objPartition.StorageMode = Microsoft.AnalysisServices.StorageMode.Molap;
                //Save Cube and all major objects to the Analysis Services
                objCube.Update(Microsoft.AnalysisServices.UpdateOptions.ExpandFull);
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Creating the Cube, MeasureGroup, Measure, and Partition Objects. Error Message -> " + ex.Message);
            }
        }
 private static void GenerateCube(Microsoft.AnalysisServices.Cube objCube, Dimension objDimension, Microsoft.AnalysisServices.MeasureGroup objMeasureGroup, string strFactTableName, string strTableKey)
        {
            try
            {
                Microsoft.AnalysisServices.CubeDimension objCubeDim = new Microsoft.AnalysisServices.CubeDimension();
                Microsoft.AnalysisServices.RegularMeasureGroupDimension objRegMGDim = new Microsoft.AnalysisServices.RegularMeasureGroupDimension();
                Microsoft.AnalysisServices.MeasureGroupAttribute objMGA = new Microsoft.AnalysisServices.MeasureGroupAttribute();
                //Add Dimension to the Cube
                objCubeDim = objCube.Dimensions.Add(objDimension.ID);// Error Here Line 451
                //Use Regular Relationship Between Dimension and FactTable Measure Group
                objRegMGDim = objMeasureGroup.Dimensions.Add(objCubeDim.ID);
                //Link TableKey in DimensionTable with TableKey in FactTable Measure Group
                objMGA = objRegMGDim.Attributes.Add(objDimension.KeyAttribute.ID);// Error Here Line 455
                objMGA.Type = Microsoft.AnalysisServices.MeasureGroupAttributeType.Granularity;
                objMGA.KeyColumns.Add(strFactTableName, strTableKey, OleDbType.Integer);
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("Error in Creating the Cube, MeasureGroup, Measure, and Partition Objects - GenerateCube. Error Message -> " + ex.Message);
            }
        }		
}// End class

Open in new window

0
Comment
Question by:homeshopper
2 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
Well, as the error states, the Dimension class you are using doesn't have an ID property. Are you sure you weren't intending to use this Dimension class (which does have an ID property)?

    http://technet.microsoft.com/en-us/library/microsoft.analysisservices.dimension.aspx
0
 

Author Comment

by:homeshopper
Comment Utility
Thanks, the link you gave me is the class I need to use.
I had a lot of 'using class' statements which was causing a conflict.
I have now been able to get all my code to work.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now