Automating Access to MTS Property Information

The PropertyInfo collection stores information about each property in a collection. See the PropertyInfo topic in the MTS Administrative Reference for more information about this collection.

To access and list the name of each property in a collection:
  1. Declare the objects that you will be using to access property information stored in the catalog.
    Dim catalog As Object
    Dim packages As Object
    Dim propertyInfo As Object
    Dim property As Object
  2. 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
  3. Call the CreateObject method to instantiate the Catalog object. Retrieve the Packages collection by calling the GetCollection method. Call the GetCollection method on the Packages collection to obtain the PropertyInfo collection. Note that the key value is left blank when calling GetCollection to access the PropertyInfo collection. The key value is not used because the information in PropertyInfo will be the same for all packages. Fill the PropertyInfo collection with information from the Catalog by using the Populate method.
    Set catalog = CreateObject("MTSAdmin.Catalog.1")
    Set packages = catalog.GetCollection("Packages")
    Set propertyInfo = packages.GetCollection("PropertyInfo", "")
    propertyInfo.Populate
  4. Enumerate through the PropertyInfo collection and list the names of each property in the collection.
    For Each property In propertyInfo
            Debug.Print property.Name
        Next
               
        Exit Sub
  5. 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