ParentObject (Role Interface)

ms132804.note(zh-cn,SQL.90).gif注意:
  下一版本的 Microsoft SQL Server 将删除该功能。请不要在新的开发工作中使用该功能,并尽快修改当前还在使用该功能的应用程序。

The ParentObject property returns a reference to the default interface of the parent object.

Applies To:clsCubeRole, clsDatabaseRole, clsMiningModelRole

Data Type

Object

The default interface and ClassType value of the returned object depends on the value of the ClassType property of the object.

Class type Returned object interface Returned object class type

clsDatabaseRole

MDStore

clsDatabase

clsCubeRole

MDStore

clsCube

clsMiningModelRole

MiningModel

clsMiningModel

Access

Read-only

Examples

Using ParentObject and ClassType properties

The following example creates a database role and assigns it to the roles collection of the first data mining model in the databases collection of mining models. It then prints some of the properties of that role's parent object by using the ParentObject property.

Dim dsoServer As New DSO.Server
Dim dsoDB As DSO.MDStore
Dim dsoDMM As DSO.MiningModel
Dim dsoDBRole As DSO.Role
Dim dsoDMMRole As DSO.Role

'Connect to the Analysis Server
  dsoServer.Connect "LocalHost"
  Set dsoDB = dsoServer.MDStores("FoodMart 2000")

'Get the first mining model
  Set dsoDMM = dsoDB.MiningModels(1)
  Debug.Print "MiningModel.Name = " & dsoDMM.Name
  
'Ensure the existence of TempRole in the database.
  Set dsoDBRole = dsoDB.Roles.AddNew("TempRole")
  
'Ensure the existence of a role.
  Set dsoDMMRole = dsoDMM.Roles.AddNew("TempRole")
  Debug.Print "MiningModel.Roles(""TempRole"").Name =" & _
    dsoDMM.Roles("TempRole").Name

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

请参阅

参考

Role Interface

帮助和信息

获取 SQL Server 2005 帮助