none
AMO code work with Console Application but not in a CLR Assemly in the database

    Question

  • Hello( i replace my question here, it was in a wrong area of the forum),
    Environnement : SQL Server 2008 R2,Visual Studio 2012, .Net 3.5


    I have a strange behavior, my code work fine in a console application an generate my AS Database, but not as an assembly


    and generate this error


    (Microsoft.AnalysisServices.OperationException: The DataItem element at line 27, column 30 (namespace http://schemas.microsoft.com/analysisservices/2003/engine) cannot appear under Envelope/Body/Execute/Command/Alter/ObjectDefinition/Dimension/Attributes/Attribute/KeyColumns.
    )


    My code  :


    Debug.WriteLine(" Create Dimension name " + md.listDimension[counter].name_dimension);
    Dimension DIM_Entity = db.Dimensions.Add(md.listDimension[counter].name_dimension);


    DIM_Entity.AttributeAllMemberName = "All " + md.listDimension[counter].name_dimension;
    DIM_Entity.Source = new DataSourceViewBinding("dsv");
    DIM_Entity.StorageMode = DimensionStorageMode.Molap;
    DimensionAttribute attr;


    attr = DIM_Entity.Attributes.Add("DIM_" + md.listDimension[counter].name_dimension + " name");


    attr.Usage = AttributeUsage.Key;


    attr.OrderBy = OrderBy.Name;
    attr.KeyColumns.Add(CreateDataItem(db.DataSourceViews[0], md.listDimension[counter].name_dimension, "id_child"));
    attr.NameColumn = CreateDataItem(db.DataSourceViews[0], md.listDimension[counter].name_dimension, "name_attr");
    // DIM_Entity.Update();
    //db.Update();
    attr.AttributeHierarchyVisible = false;


    // DIM_Entity.Update();
    //db.Update();




    attr = DIM_Entity.Attributes.Add(md.listDimension[counter].name_dimension);
    attr.Type = AttributeType.Regular;
    attr.Usage = AttributeUsage.Parent;
    attr.OrderBy = OrderBy.Name;
    attr.KeyColumns.Add(CreateDataItem(db.DataSourceViews[0], md.listDimension[counter].name_dimension, "id_parent"));
    attr.NameColumn = CreateDataItem(db.DataSourceViews[0], md.listDimension[counter].name_dimension, "name_attr");
    DIM_Entity.Update(UpdateOptions.ExpandFull);




    Thanks you very much
    Thursday, February 16, 2012 4:39 PM

Answers

All replies