我正在尝试使用C#代码中的MDX ADOMD命令永久创建计算维度成员。 以下MDX脚本创建成员,但它仅适用于当前会话。
CREATE MEMBER [Cube].[Dimension].[Hierarchy].[My Member Name] as
Aggregate({
[Dimension].[Hierarchy].[Level].&[1], [Dimension].[Hierarchy].[Level].&[2], ...
})
如何永久创建它?
答案 0 :(得分:1)
从未尝试过,但我发现了一些看似这样做的AMO代码,它正在从多维数据集加载当前的MDX计算脚本,添加到它,然后将其发回。
Dim objServer As Server
Dim objDatabase As Database
Dim strDataBaseID As String
Dim objCube As Cube
Dim objMdxScript As MdxScript
Dim objCommand As Command
Dim strCommand As String
objServer = New Server
objServer.Connect(“localhost”)
objDatabase = objServer.Databases(“Adventure Works DW 2008″)
strDataBaseID = objDatabase.ID
If objDatabase.Cubes.Count > 0 Then
objCube = objDatabase.Cubes(“Adventure Works”)
If objCube.MdxScripts.Count > 0 Then
objMdxScript = objCube.MdxScripts(“MdxScript”)
”objMdxScript = objCube.MdxScripts(0)
Else
objCube.MdxScripts.Add(“MdxScript”, “MdxScript”)
objMdxScript = objCube.MdxScripts(“MdxScript”)
End If
objCommand = New Command
strCommand = “CREATE MEMBER CURRENTCUBE.[Measures].[Multipy Measures By 20]“
strCommand = strCommand & ” AS [Measures].[Internet Sales Amount] * 20, “
strCommand = strCommand & ” VISIBLE = 1 ; “
objCommand.Text = strCommand
objMdxScript.Commands.Add(objCommand)
objMdxScript.Update()
objCube.Update()
End If
objServer.Disconnect()
我在其他地方使用AMO,但没有像这样使用它,所以请回报结果:)