本人翻譯的微軟DSO資料

前段時間在做一個決策支持系統項目,使用了微軟的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

 

 

發佈了30 篇原創文章 · 獲贊 3 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章