Automating Access to MTS Related Collection Names
The RelatedCollectionInfo collection provides a list of related collections that you can access from a given collection. See the RelatedCollectionInfo topic in the MTS Administrative Reference for a list of properties supported by this collection.
To access and display related collection names:
-
Declare the objects that you will be using to access the object that provides the names of related collections
Dim catalog As Object
Dim packages As Object
Dim RelatedCollectionInfo As Object
Dim collName As Object
-
Use the On Error statement to handle run-time errors if a method returns a failure HRESULT. You can test and respond to MTS trappable errors using the On Error statement and the Err object.
On Error GoTo failed
-
Call the CreateObject method to instantiate the Catalog object. Retrieve the Packages collection by calling the GetCollection method. Then call the GetCollection method on the Packages collection object to obtain the RelatedCollectionInfo collection. Note that the key value is left blank when calling GetCollection to access the RelatedCollectionInfo collection. The key value is not used because the information in RelatedCollectionInfo will be the same for all packages. Fill the RelatedCollectionInfo collection with information from the catalog by calling the Populate method.
Set catalog = CreateObject("MTSAdmin.Catalog.1")
Set packages = catalog.GetCollection("Packages")
Set RelatedCollectionInfo =_ packages.GetCollection("RelatedCollectionInfo", "")
RelatedCollectionInfo.Populate
-
Enumerate through the RelatedCollectionInfo collection and display the names of each collection.
For Each collName In RelatedCollectionInfo
Debug.Print collName.Name
Next
Exit Sub
-
Use the Err object to display an error message if the installation of the package fails.
failed:
MsgBox "Failure code " + Str$(Err.Number)
End Sub
See Also
MTS Administration Objects, MTS Collection Types, MTS Administration Object Methods, Automating MTS Administration with Visual Basic