共用方式為


Parent (Role Interface)

[!附註]

  下一版的 Microsoft SQL Server 將不再提供此功能。請勿在新的開發工作中使用此功能,並且儘速修改使用此功能的應用程式。

The Parent property of the Role interface contains a reference to the parent MDStore object.

Applies To:clsCubeRole, clsDatabaseRole, clsMiningModelRole

Data Type

MDStore

The ClassType value of the returned object depends on the value of the ClassType property of the object.

Class type

Returned object class type

clsDatabaseRole

clsDatabase

clsCubeRole

clsCube

clsMiningModelRole

Nothing

Access

Read-only

備註

This property will return Nothing for mining model roles, because data mining models do not support the MDStore interface. To obtain the parent object of a mining model role, use the ParentObject property.

Examples

Using the Parent and ClassType properties

The following example creates a database role and assigns it to the first cube in the database object's collection of cubes. It then prints some of the properties of the parent object by using the role object's Parent property.

Dim dsoServer As New DSO.Server
Dim dsoDB As DSO.MDStore
Dim dsoCube As DSO.MDStore
Dim dsoDBRole As DSO.Role
Dim dsoCubeRole As DSO.Role

'Connect to the Analysis Server
  dsoServer.Connect "LocalHost"
  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
  
'Ensure the existence of TempRole in the database.
  Set dsoDBRole = dsoDB.Roles.AddNew("TempRole")
  
'Add the command to cube's collection of commands.
  Set dsoCubeRole = dsoCube.Roles.AddNew("TempRole")
  Debug.Print "Cube.Roles(""TempRole"").Name =" & _
    dsoCube.Roles("TempRole").Name

'Print the roles .ParentObject properties
  Debug.Print "   .Parent properties" & vbCrLf & _
    "   -----------"
  Debug.Print "   TypeName(""dsoCubeRole.Parent"") = " & _
    TypeName(dsoCubeRole.Parent)
  If dsoCubeRole.Parent.ClassType = clsCube Then
    Debug.Print "   .ClassType = clsCube"
  Else
    Debug.Print "This line should never be executed."
  End If
  Debug.Print "   .Description = " & dsoCubeRole.Parent.Description
  Debug.Print "   .Name = " & dsoCubeRole.Parent.Name
  
  dsoCube.Roles.Remove ("TempRole")
  dsoDB.Roles.Remove ("TempRole")