微软DSO资料(转至menliwxj的专栏)

来源:互联网 发布:java 网格袋布局 编辑:程序博客网 时间:2024/05/08 16:58
原文:http://blog.csdn.net/menliwxj/


前段时间在做一个决策支持系统项目,使用了微软的AS,查了很多资料,却没有中文的,只好自己翻译了(因为自己英文比较烂,所以才翻译嘛).现在把它献出来,以供有需要的朋友参考.


DSO决策支系统程序员参考

 

概述

微软SQL Server 2000分析服务为你提供了真正的机会来创建与整合自定义应用程序。服务器对象模型DSO提供了能通过COM自动化程序语言(如VB5.0与后续版本)来使用的接口与对象。此外,VC++程序员也可以使用DSODSO对象同时支持早期或延后绑定。

程序员参考提供了使用DSO的细节信息,以用于开发与分析服务器交互的自定义应用程序。关于使用AS的其它程序工具的更多信息,请参阅“编写AS应用程序”一节。

本部分的主题覆盖了以下内容:

主题

描述

Interfaces(接口)

关于你编程操作DSO对象的每个接口的细节,包括接口管理的集合、方法与属性。

Events(事件)

DSO对象支持的事故明细,包括数据库报告与对象处理事件。

Objects(对象)

关于DSO对象的信息。对象的主题由它们拥用的默认接口提供,还包括特定对象的集合、方法与属性。

Enumerations(枚举)

DSO提供的枚举细节与关于如何使用它们的信息

Collections(集合)

DSO中使用的关于集合的信息,包括应用这些集合的常用方法与属性。

 

接口

DSO中有话多接口。对象拥有相似功能实现的公共接口。举几个例子:数据库、多维数据集、分区,以及聚合实现了MDStore接口。MDStore对象是一个多维数据容器。数据库包含多维数据集的关系信息,多维数据集包含存储数据的分区,以及聚合是分区中预先计算好的关联数据的摘要。MDStore对象拥有类似的结构。它们包含分类数据的维度集合,指定关系数据管理系统的数据源包含事故和维度表,定义安全权限的规则,等等。

给一个参考给MDStore接口或其它DSO接口,你能通过测试ClassType属性来确定是哪个类型的对象。实现了MDStore接口的对象可以是以下类型:clsDatabaseclsCubeclsPartitionclsAggregation。贯穿本参考,DSO对象都用前缀符号“cls“标识。DSO 类类型枚举包括所有DSO类类型的完整列表。

不是所有对象都用相同的方法来实现公用接口的,一些对象不实现所有的接口属性、方法与集合。例如,数据库对象(clsDatabase)实现了MDStore公用接口的BeginTrans方法,但立方对象(clsCube)则没有实现。一些对象限制处理某些属性以例于它他成为只读属性,而不是可读/写的。如果你尝试处理一个没有实现的属性或调用一个没有实现的方法,DSO会抛出一个错误。

DSO暴露了CommandDimensionLevelMDStoreMeasure,及Role通用接口。下表列出了DSO通用接口及实现它们的对象类型。

接口

描述

实现对象

Command

Command接口暴露了定义与管理在客户端与AS上执行MDX语句的功能

clsDatabaseCommand

clsCubeCommand

clsRoleCommand

Dimension

Dimension接口定义了属性、方法与集合,你可以用来操作不同类型的维度:数据库维、多维数据集维、分区维以及聚合维。

clsCubeDimension

clsPartitionDimension

clsAggregationDimension

Level

Level接口定义了对象来说明维度的层次

clsDatabaseLevel

clsCubeLevel

clsPartitionLevel

clsAggregationLevel

MDStore

实现MDStore接口的对象均包含以下维:

数据库、多维数据集、分区与聚合

clsDatabase

clsCube

clsPartition

clsAggregation

Measure

实现Measure接口的对象描述了存储在多维数据集,分区,与聚合中的值。

clsCubeMeasure

clsPartitionMeasure

clsAggregationMeasure

Role

实现Role接口的对象包含数据库、多维数据集,与数据挖掘模型的处理权限

clsDatabaseRole

clsCubeRole

clsMiningModelRole

 

一些DSO对象没有实现通用接口。你可以使用这些对象的默认接口:clsServerclsDataSourceclsMiningModelclsColumnclsCubeAnalyzerclsPartitionAnalyzer,与clsMemberProperty

 

备注:

DSO类库暴露了许多对象类,例如CubeDatabasePartitionCubeDimension等等。这些对象保留到将来使用并且有意不使用在DSO应用程序中。你应使用通用接口来代替。举个例子,使用以下代码来创建一个类类型为clsDatabase的对象(一个数据库对象实现了MDStore接口):

‘Assume an object (dsoServer) of ClassType clsServer exists.

‘Add database object to server's MDStores collection.

Dim dsoDB As MDStore  

‘Declare the object by the interface.

Set dsoDB = dsoServer.MDStores.AddNew("MyDB")

 

经常使用恰当的对象的通用接口。举个例子,主要的对象类型都使用了MDStore接口作为它们的专用接口。下面的代码例子显示了使用Cube对象的专用接口:

' INCORRECT - DO NOT USE.
private dsoCube As DSO.Cube  
' CORRECT
Private dsoCube As DSO.MDStore   

这个规则的唯一例外就是Database对象。如果你的客户端应用程序需要捕获数据库事件,对象的许多接口应用MDStore来代替,如下面的代码所示:

' Use this statement if you do not need to trap events.
Public dsoDB as DSO.MDStore 
' Use this statement if you need to trap events.
Public WithEvents dsoDB as DSO.Database 

Command接口

DSO中,某些对象可以包含一组用户自定义的命令,以便于你处理对象时这些命令在数据透视表服务客户端自动执行。这些命令可以包括MDX表示的表达式,如定义计算成员,命名集,库资源,及其它命令。

安全提示 命令可能是安全漏洞源;它们可以调用系统或用户自定义的函数而不需要用户知识或干预,且包含存储在简单文本中的安全许可。在实现这些命令前,回顾一下安全问题的命令文本。

实现了Command接口的对象,CubeCommandDBCommand,与RoleCommand,属性ClassType都有各自的值clsCubeCommandclsDatabaseCommandclsRoleCommandCommand接口提供了集合、方法与属性来操作这些对象。

应用于:

clsCubeCommand

clsDatabaseCommand

clsRoleCommand

集合:

Command接口包含以下集合:

集合

描述

CustomProperties

Command对象的用户自定义属性

方法:

Command接口包含以下方法:

方法

描述

Clone

拷贝一个已存在的对象到相同类型的目标对象。

LockObject

锁定一个对象

UnlockObject

解锁一个先前被锁定的对象

Update

保存Command对象的定义到元数据知识库中。

属性:

命令接口支持以下属性:

属性

描述

ClassType

返回标识特定类类型的枚举常量。

CommandType

返回标识命令用途的枚举常量。

Description

设置或返回命令对象的描述。

IsValid

指出NameStatement属性是否为空,命令对象是否属于一个集合

Name

设置或返回命令对象的名称

OrdinalPosition

返回命令对象在父对象MDStoreCommands集合中的索引号

Parent

返回父对象MDStore的参考

ParentObject

返回当前对象为子对象的父对象的参考

Statement

设置或返回命令文本

SubClassType

返回标识对象的子类类型的枚举常量

clsCubeCommand

类类型为clsCubeCommand的对象提供了特殊的DSO Command接口实现。该对象通过Command接口提供了集合与属性,但没有相关的方法。

备注:

当多维数据集包含要处理的命令时,类类型为clsCubeCommand的对象会自动执行MSSQL2000 AS上压缩了命令。你通过增加一个命令到多维数据集的Commands集合中来为多维数据集增加命令,这种命令包括计算成员,命名集,类参考,以及其它。

需要了解更多信息,请参阅“DSO简介”

例子

创建一个类类型为clsCubeCommand的对象。用以下代码来实现:

'Assume an object (dsoServer) of ClassType clsServer exists

'with existing database and cube

Dim dsoDB As DSO.MDStore     

'Database

Dim dsoCube As DSO.MDStore  

'Cube

Dim dsoCmd As DSO.Command  

'Command

Set dsoDB = dsoServer.MDStores(1)

Set dsoCube = dsoDB.MDStores(1)

Set dsoCmd = dsoCube.Commands.AddNew("CubeCmd1")

clsDatabaseCommand

类类型为clsDatabaseCommand的对象为DSO Command接口提供了特殊的实现。该对象通过Command接口提供集合、方法与属性。

备注

当数据库包含的命令在处理时,MSSQL 2000 AS客户端上会自动执行类型为clsDatabaseCommand的对象压缩了的用户自定义命令。你可以通过向数据库的Commands集合增加命令来实现向数据库增加命令。这些命令包括计算成员、命名集、类参考、等等。

例子

'Assume an object (dsoServer) of ClassType clsServer exists

‘with an existing database

Dim dsoDB As DSO.MDStore     

'Database

Dim dsoCmd As DSO.Command  

'Command

Set dsoDB = dsoServer.MDStores(1)

Set dsoCmd = dsoDB.Commands.AddNew("DBCmd1")

clsRoleCommand

类类型为clsRoleCommand的对象为Command接口提供了特殊的实现。这些对象通过Command接口提供集合与属性,但没有相关方法的实现。

备注

当数据库包含的命令在处理时,MSSQL 2000 AS客户端上会自动执行类型为clsRoleCommand的对象压缩了的用户自定义命令。你可以通过向规则的Commands集合增加命令来实现向规则中增加命令。这些命令包括计算成员、命名集、类参考、等等。

举个例子,你可能想授权给一个计算成员以SalesBonus成员的管理规则,但不想给SalesPerson规则。维护SalesBonus计算成员的命令在处理包含这个规则命令的多维数据集时会自动执行。

例子

使用以下代码来创建一个类型为clsRoleCommand的对象:

'Assume an object (dsoDB) of ClassType clsDatabase exists

Dim dsoRole As DSO.Role  

'Role

Dim dsoCmd As DSO.Command  

'Command

Set dsoRole = dsoDB.Roles(1)

Set dsoCmd = dsoRole.Commands.AddNew("RoleCmd1")

集合 CustomProperties

CustomProperties集合应用到所有DSO对象中,允许你为DSO对象定义唯一属性。CustomProperties集合包含与DSO对象相关的你定义用来存储信息的属性对象。要了解关于定义自定义属性的更多信息,请参阅“属性对象”一节。

权限

/

备注

CustomProperties集合实现了它自己的方法与属性,与其它DSO集合的操作有很大的不同。

例子

下面的代码例子展示了增加与找回自定义属性对象:

' Assume the existence of an object of ClassType clsDimension.

' Add a custom property. 

Dim dsoProp As DSO.Property 

Set dsoProp = dsoDim.CustomProperties.Add(55, "Age", vbInteger)

' Retrieve custom property values. 

Dim dsoProp2 As DSO.Property 

Set dsoProp2 = dsoDim.CustomProperties(1) 

Debug.Print dsoProp2.Name, dsoProp2.Value

方法 Clone

Command接口的Clone命令拷贝一个已存在的对象的属性至相同类型的目标对象。目标对象必须预先存在已使用Clone方法。

应用于

clsDatabaseCommand

语法

object.Clone(ByVal TargetObject as Command,[ByVal Options As CloneOptions=cloneMajorChildren])

Object:拷贝对象

TargetObject:预先创建的相同类型的对象

Options:对于类型为clsDatabaseCommand的对象,CloneOptions不产生影响并被忽略。

例子

下面的例子展示了如何拷贝一个命令对象:

'Assume a command object (dsoCmd) exists.

Dim dsoCmdCopy as new DSO.Command

dsoCmd.Clone dsoCmdCopy

方法 LockObject

Command 接口的LockObject方法锁定对象来防止多用户同时改变对象。

应用于

clsDatabaseCommand

语法

object.LockObject(ByVal LockType as OlapLockTypes,ByVal LockDescription as string)

object 要锁定的对象

LockType OlapLockType枚举中其中一个锁定类型。

OlapLockType LockObject方法的LockType参数的枚举值,DSO类库中的绝大多数对象都实现了。

常量

描述

OlapLockExtendedRead

其它应用程序可以读对象的属性,但它们不能改变或处理。这个锁定用于防止该对象所依赖的对象正在处理,例如多维数据集的共享维度,olapLockExtendedRead多用户锁可以应用于多用户应用程序的对象中。但是,没有应用程序可以锁定正在处理或更新的对象直至所有的olapLockExtendedRead锁都释放了。

OlapLockProcess

对象的Process方法可以启动,其它的应用程序只可以读对象的属性直到锁释放。同一时间一个对象只能有一个olapLockProcess锁,在对象启用了olapLockProcess锁之后,其它应用程序只可以应用OlapLockRead锁。

OlapLockRead

在锁未释放前,对象的属性可以从知识库中读取,不能被其它的应用程序改变。应用olapLockRead锁时,其它应用程序可以应用olapLockReadolapLockExtendedRead,以及olapLockProcess锁,但不能用olapLockWrite锁。

OlapLockWrite

对象的属性可以用Update方法来修改知识库,在锁未释放前,其它应有程序的引用都会无效,没有其它类型的锁可以应用于该对象。

方法 UnlockObject

Command接口的UnlockObject方法释放先前由LockObject方法加上的锁。

应用于

clsDatabaseCommand

语法

Object.UnlockObject

Object:要解锁的对象

备注

如果应用程序创建的一个或多个锁在用UnlockObject方法释放前就终止了,当应用程序关闭时AS会自动释放这些锁。

例子

下面的例子是展示加锁一个Command对象以便于修改它,然后解锁与更新它的知识库信息。

'Assume a command object (dsoCmd) exists.

dsoCmd.LockObect OlapLockRead, "Updating command, please wait."

' (Insert code to change command object here.)

dsoCmd.UpdatedsoCmd.UnlockObject

方法 Update

Command接口的Update方法将一个命令对象的定义保存到元数据知识库中。

应用于

clsDatabaseCommand

语法

Object.Update

Object:要更新的命令对象

备注

当你想保存对对象所作的修改时使用这个方法。任何改变都会让对象拥有一个会话直至这个方法被执行。

例子

下例展示了锁定一个命令对象以便于进行修改,然后解锁并更它的知识库信息。

'Assume a command object (dsoCmd) exists.

dsoCmd.LockObect OlapLockRead, "Updating command, please wait."

' (insert code to change command object here)

dsoCmd.UpdatedsoCmd.UnlockObject

属性 ClassType

Command接口的ClassType属性包含一个枚举常量,用来标识类在DSO对象模型中的名称。

应用于

clsCubeCommand

clsDatabaseCommand

clsRoleCommand

数据类型 ClassTypes

存取 只读

例子

使用下列的代码返回一个命令对象的类类型,及测试返回的是哪个类型的对象:

'Assume an object (dsoCommand) of ClassType clsCommand exists.

Dim enuClassType As DSO.ClassTypes

enuClassType = dsoCommand.ClassType

Select Case enuClassType   

Case clsDatabaseCommand       

' Insert code for a database command.   

Case clsCubeCommand       

' Insert code for a cube command.   

Case clsRoleCommand       

' Insert code for a role command   

Case Else       

' Insert code for when this is not a command object.

End Select

属性 CommandType

Command接口的CommandType属性包含一个枚举常量来标识命令选项。

应用于

clsCubeCommand

clsDatabaseCommand

clsRoleCommand

数据类型 CommandTypes

存取权限 /

备注

CommandType的值测试AS是如何解释命令对象的。下表列出了可能的值:

CommandType

描述

cmdCreateAction

命令包括了一个创建活动语法。

cmdCreateMember

命令定义了一个或多个计算成员

cmdCreateSet

命令定义了一个或多个已存在成员的集合

cmdUseLibrary

命令指定一个第三方DLL,它包含注册用于MDX中的函数。

cmdUnknown

命令定义了不包括其它任何一种命令类型的语法,就像DROP MEMBER语法或在未来的版本中会加进来的语法

注意 这个命令类型仅用于在没有其它任何命令类型的语法相符时

cmdCreateCellCalculation

命令定义了一个计算单元声明。

 

重要的是保证与AS的兼容性,你应为每个命令只创建一个活动,计算成员,命名集或计算单元定义。

例子

A. 指定一个命令类型

使用下面的代码来为一个已存在的命令对象指定一个命令类型:

CommandObject.CommandType = cmdCreateMember

B. 测试命令类型

使用以下代码来测试在使用的命令类型:

Dim CommandType As DSO.CommandTypes

CommandType = CommandObject.CommandType

Select Case CommandType   

Case cmdCreateAction       

' Insert code to create an action.   

Case cmdCreateMember       

' Insert code to define a calculated member.     

Case cmsCreateSet       

' Insert code to define a named set of existing members.    

Case cmdUseLibrary       

' Insert code to use a third-party library.    

Case cmdCreateCellCalculation       

' Insert code to create a calculated cells definition.  

Case cmdUnknown       

' Insert code to define other statements.

End Select

属性 Description

Command接口的Description属性包含命令对象的描述。

应用于

clsCubeCommand

clsDatabaseCommand

clsRoleCommand

数据类型 String

存取 /

备注

识别命令对象的主要机制是Name属性。使用Description属性的意图是提供额外的描述信息。

例子

'Assume a command object (dsoCmd) exists.

dsoCmd.Description = "Create a new profit member as sales-cost."

属性 IsValid

Command接口的IsValid属性指出NameStatement是否为空以及命令对象是否一直属于一个集合。

应用于

clsCubeCommand

clsDatabaseCommand

clsRoleCommand

数据类型 Boolean

存取 只读

备注

因为命令对象灵活的种类,仅有以下检查会执行:

l         命令对象的Name属性不为空

l         命令对象一直属于一个Commands集合

l         命令对象的Statement属性不为空

执行命令是唯一测试命令功能是否正确的途径。

例子

'Assume a command object (dsoCmd) exists.

If dsoCmd.IsValid Then  

'Insert code to save the command.

Else  

'Return an error with one or more properties.

End If

属性 Name

命令接口的Name属性包含命令对象的名称。这个属性是识别命令对象个体的主要机制。

应用于

clsCubeCommand

clsDatabaseCommand

clsRoleCommand

数据类型 String

存取 /(对象被命名后为只读)

备注

在一个立方中,每个命令必须有一个唯一存在的名称。关于DSO的名称协定的更多信息,请参见“DSO的命名约定”一节。

例子

‘Assume a Command Object(dsoCmd) exists.

Debug.print dsoCmd.Name

属性 OrdinalPosition

Command接口的OrdinalPosition属性包含命令在父对象MDStore的命令集中的索引号。

应用于

clsCubeCommand

clsDatabaseCommand

clsRoleCommand

数据类型 Integer

存取 只读

备注

位置索引号测试命令集中命令的执行顺序。在一个命令依赖其它命令时这个索引号非常重要(例如:CREATE SET命令使用CREATE MEMBER命令定义的成员)。基于这个原因,CREATE MEMBER 命令应该拥有一个比CREATE SET命令更低的OrdianlPosition属性值。不过,命令的执行顺序位置不影响计算成员或命令可能创建的计算单元定义的解答顺序。更多信息请参阅“理解途径顺序与解答顺序”。

例子

下面的代码展示了在FoodMart 2000数据库的命令集中创建三个新命令。然后列举集合内容,打印OrdinalPositionName属性至调试窗口。接下来,代码示例删除与重建第一个命令,再次列举集合示范其它命令的Ordinal Position变化。

Dim dsoServer As New DSO.Server   

Dim dsoDB As DSO.MDStore   

Dim dsoCmd As DSO.Command       

' Connect to the local Analysis server.   

dsoServer.Connect "LocalHost"       

' Open the FoodMart 2000 database.   

Set dsoDB = dsoServer.MDStores("FoodMart 2000")       

' Add three sample commands.   

Set dsoCmd = dsoDB.Commands.AddNew("Command3")   

Set dsoCmd = dsoDB.Commands.AddNew("Command1")   

Set dsoCmd = dsoDB.Commands.AddNew("Command2")       

' Iterate through the commands for the database.   

For Each dsoCmd In dsoDB.Commands       

' Print its name and ordinal position       

Debug.Print dsoCmd.OrdinalPosition & " = " & dsoCmd.Name   

Next   

' Now, delete the Command3 command and add it again.   

dsoDB.Commands.Remove "Command3"   

Set dsoCmd = dsoDB.Commands.AddNew("Command3")       

' Iterate again through the commands for the database.   

Debug.Print "-----"   

For Each dsoCmd In dsoDB.Commands       

' Print its name and ordinal position       

Debug.Print dsoCmd.OrdinalPosition & " = " & dsoCmd.Name   

Next

属性 Parent

Command接口的Parent属性包括父对象MDStore的参考。

应用于

clsCubeCommand

clsDatabaseCommand

clsRoleCommand

数据类型 MDStore

存取 只读

备注

父对象的类依赖命令对象的类。

特别的如果命令对象拥有一个ClassType属性为clsRoleCommand且与数据挖掘模型规则相关的话,该属性就返回Nothing。数据挖掘模型没有实现MDStore接口,因此不能使用这个属性。

命令对象类

父对象类

clsDatabaseCommand

clsDatabase

clsCubeComand

clsCube

clsRoleCommand

ClsCube

clsDatabase

 

例子

下面的例子展示了创建一个立方命令及将其赋给FoodMart2000数据库的第一个立方的MDStore集合,然后通过立方命令对象的Parent属性打印父对象的其中一些属性。

Dim dsoServer As New DSO.Server

Dim dsoDB As DSO.MDStore

Dim dsoCube As DSO.MDStore

Dim dsoDBCmd As DSO.Command

Dim dsoCubeCmd As DSO.Command

' Connect to the Analysis server.   

dsoServer.Connect "LocalHost"

' Get a reference to the FoodMart 2000 database.   

Set dsoDB = dsoServer.MDStores("FoodMart 2000")

' Get the first cube in the database's collection.   

Set dsoCube = dsoDB.MDStores(1)    

Debug.Print "Cube.Name = " & dsoCube.Name

' Add the command to the cube's collection.   

Set dsoCubeCmd = dsoCube.Commands.AddNew("TempCommand")   

Debug.Print "Cube.Commands(""TempCommand"").Name =" _     

  & dsoCube.Commands("TempCommand").Name

' Print the properties of the command's

' Parent object.   

Debug.Print "   .Parent properties" & vbCrLf & _       

"   -----------"   

Debug.Print "   TypeName(dsoCubeCmd.Parent) = " & _

TypeName(dsoCubeCmd.Parent)   

If dsoCubeCmd.Parent.ClassType = clsCube Then      

Debug.Print "   .ClassType = clsCube"   

Else       

Debug.Print "This line should never be executed."   

End If   

Debug.Print "   .Description = " & dsoCubeCmd.Parent.Description   

Debug.Print "   .Name = " & dsoCubeCmd.Parent.Name   

dsoCube.Commands.Remove ("TempCommand")

属性 ParentObject

ParentObject属性返回一个延迟绑定参考到父对象的默认接口。

应用于

clsCubeCommand

clsDatabaseCommand

clsRoleCommand

数据类型 Object

存取 只读

备注

这个属性返回命令对象的父对象的默认接口。对于ClassType属性值为clsRoleCommand的对象,这个属性返回ClassTypeclsCubeRoleclsDatabaseRole的对象。这个属性的行为与Parent属性不一样。Parent属性返回命令对象最靠近的MDStore父参考,它或许是或许不是直接的父参考,要依赖命令对象的ClassType。这个属性返回命令对象的父参考而不管接口。当你使用classTypeclsRoleCommand的命令对象时这个行为区别是很明显的。

Class Type

父对象接口

父对象类类型

clsDatabaseCommand

MDStore

clsDatabase

clsCubeCommand

MDStore

ClsCube

clsRoleCommand

Role

clsDatabaseRole

clsCubeRole

clsMiningModelRole

 

例子

比较ParentParentObject属性

下面的例子比较使用ParentParentObject属性。

Dim dsoServer As New DSO.Server

Dim dsoDB As DSO.MDStore

Dim dsoRole As DSO.Role

Dim dsoRoleCmd As DSO.Command

Dim dsoDatabaseRole As DSO.Role 

dsoServer.Connect "LocalHost" 

Set dsoDB = dsoServer.MDStores("FoodMart 2000")

'Get the first role in the database.

'This should be the Everyone role. 

Set dsoRole = dsoDB.Roles(1) 

Debug.Print "DatabaseRole.Name = " & dsoRole.Name

'Add a new command to the role. 

Set dsoRoleCmd = dsoRole.Commands.AddNew("RoleCmd")   

'Print the properties of the Parent object. 

Debug.Print ".Parent properties" & vbCrLf & "---------" 

Debug.Print "Interface type = " & TypeName(dsoRoleCmd.Parent) 

If dsoRoleCmd.Parent.ClassType = clsDatabase Then   

Debug.Print ".ClassType = clsDatabase" 

Else   

Debug.Print "This should never be printed." 

End If 

Debug.Print ".Description = " & dsoRoleCmd.Parent.Description 

Debug.Print ".Name = " & dsoRoleCmd.Parent.Name

'Print the properties of the ParentObject object 

Debug.Print ".ParentObject properties" & vbCrLf & "---------" 

Debug.Print "Interface type = " & TypeName(dsoRoleCmd.ParentObject) 

Set dsoDatabaseRole = dsoRoleCmd.ParentObject 

If dsoDatabaseRole.ClassType = clsDatabaseRole Then     

Debug.Print ".ClassType = clsDatabaseRole" 

Else   

Debug.Print "This should never be printed." 

End If 

Debug.Print ".ClassType = " & dsoDatabaseRole.ClassType 

Debug.Print ".Description = " & dsoDatabaseRole.Description 

Debug.Print ".Name = " & dsoDatabaseRole.Name

属性 Statement

Command接口的Statement属性包含命令语法文本。

应用于

clsCubeCommand

clsDatabaseCommand

clsRoleCommand

数据类型 String

存取 /

备注

关于命令语句的更多信息,请参阅“命令类型”一节。

语句中用到的名称如定义活动、计算成员、命名集,以及计算单元必须在立方中是唯一的。例如,如果你创建一个活动并命名为Test,你不会再创建一个计算单元定义也命名为Test

例子

A. 创建一个命令对象(cmdCreateAction)

使用以下代码来创建一个cmdCreateAction类型的命令对象:

CommandObject.Statement = "CREATE ACTION Sales.ShowCustDetails " & _   

"FOR [Customer] MEMBERS As " & _ 

"'IIf(Customers.CurrentMember.Properties(""Existing Customer"")" & _

" = ""True""," & _

"""http://MyServer/CustomerDetails.ASP?CustID="" + " & _

"Customers.CurrentMember.ID,'') " & _

"TYPE = URL " & _

"APPLICATION = 'IE' " & _

"DESCRIPTION = 'Launch the customer details page for " & _

"this specific customer.'"

你可以在命令语句中使用CURRENTCUBE来指明包含命令对象的立方。这个保留字使得在立方之间拷贝命令对象变得容易多了。例如,你可以像下面的代码一样重写前面的代码:

CommandObject.Statement = "CREATE ACTION CURRENTCUBE.ShowCustDetails " & _

"FOR [Customer] MEMBERS As " & _

"'IIf(Customers.CurrentMember.Properties(""Existing Customer"")" & _

" = ""True""," & _

"""http://MyServer/CustomerDetails.ASP?CustID="" + " & _

"Customers.CurrentMember.ID,'') " & _

"TYPE = URL " & _

"APPLICATION = 'IE' " & _

"DESCRIPTION = 'Open the customer details page for " & _

"this specific customer.'"

B. 创建一个命令对象(cmdCreateMember)

CommandObject.Statement = "CREATE MEMBER Sales.Measures.PROFIT AS " & _

"'Measures.Sales - Measures.Cost'"

C. 创建一个命令对象(cmdCreateSet)

CommandObject.Statement = "CREATE SET CURRENTCUBE.[ImportedBeer] AS " & _

"'Filter(Product.Members, " & _

"(InStr(1, Product.CurrentMember.Name, ""Imported Beer"")))'"

D.创建一个命令对象(cmdUseLibrary)

CommandObject.Statement = _

"USE LIBRARY ""C:/SampleDirectory/MyStatFunctions.dll"""

E. 创建一个命令对象(cmdCreateCellCalculation

CommandObject.Statement = CREATE SESSION CELL CALCULATION " & _

"[Sales].[Mexico Adjustments] FOR " & _

"'(Descendants([Mexico], [City], SELF))' & _

"AS '<expression>'," & _

"CONDITION = '[Time].CURRENTMEMBER.NAME=[2000]'"

F. 返回一个命令对象语句。

Dim strCommandStatement As String

strCommandStatement = CommandObject.Statement

属性 SubClassType

Command接口的SubClassType包含一个枚举常量用来识别对象的子类类型。实现了Command接口的对象通常都有SubClassTypesbclsRegular属性。

应用于

clsCubeCommand

clsDatabaseCommand

clsRoleCommand

数据类型 subclassTypes

存取 只读

MDStore接口

MDStore接口实现了包含多维数据的DSO对象,下表包含了这些对象:

对象

描述

Database

在分析服务器里表示数据库的对象。数据库包含立方,维度,挖掘模型与规则

Cube

在分析服务器里表示立方的对象。立方包含维度,汇总,与命令

Partition

表示立方中数据的物理存储方式的对象。分区包含维度,汇总与集合

Aggregation

表示立方中集合数据表的对象。包含维度,汇总与成员属性

 

通过这些对象实现的接口,MDStore接口是用来使用这些对象的主要接口。要区分实现了MDStore接口的对象,可以使用ClassType属性。下表列出了实现MDStore接口的对象及与ClassType属性相关的值:

对象

ClassType

Database

clsDatabase

Cube

clsCube

Partition

clsPartition

Aggregation

clsAggregation

 

原创粉丝点击