Automating Configuration of an MTS Client to Use Remote Components

To configure a client to use the Bank.CreateTable remote component:
  1. Declare the objects that you will be using to configure a client (running MTS) to run remote components.
    Dim catalog As Object
    Dim remoteComps As Object
    Dim util 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 RemoteComponents collection by calling the GetCollection method. Then instantiate the RemoteComponentUtil object by using the GetUtilInterface method. To install the remote component, call the InstallRemoteComponentByName method and supply the name of the server computer, the package name on the server, and the component name.
    Set catalog = CreateObject("MTSAdmin.Catalog.1")
    Set remoteComps = catalog.GetCollection("RemoteComponents")
    Set util = remoteComps.GetUtilInterface
    util.InstallRemoteComponentByName "remote1", "New","Bank.CreateTable"
    Exit Sub
  4. Use the Err object to display an error message if the installation of the component 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