AMO code work with Console Application but not in a CLR Assemly in the database
-
Thursday, February 16, 2012 4:39 PMHello( 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
All Replies
-
Monday, February 20, 2012 6:22 AMModerator
Hi Vincent.diallonort,
It might be more helpful to launch this question in SQL Server Analysis Service forum. Please have a look at these two threads if to see they help:
Adding assembly file to AS database via AMO
Trying to add dimension attributes through CLR
Stephanie Lv
TechNet Community Support
- Marked As Answer by Stephanie LvModerator Thursday, February 23, 2012 1:21 AM
-
Wednesday, February 22, 2012 2:44 PM
Thanks, i reply on this post. It's helpful.
have a good day
Vincent

