Share via


Enumerating Routes Sample

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

The following example displays the name of each Commerce Server Staging (CSS) route that is defined on a replication server.

Option Explicit 
On Error Resume Next

const CSS_ERROR_NO_ROUTES_DEFINED = &hC000EEDA
const CSS_ERROR_NO_MORE_ITEMS  = &h8000EEEB

dim ReplicationServer
dim ReplicationRoute
dim Iterator

set ReplicationServer = CreateObject("CssApi.ReplicationServer")
ReplicationServer.Initialize("")

Wscript.Echo "The server has the following routes:"

Iterator = 0
do while True
'Clear any error text.
Err.Clear

'Get the next route.
set ReplicationRoute = ReplicationServer.EnumRoutes(Iterator)

'Quit if no routes are defined on the server.
if Err.Number = CSS_ERROR_NO_ROUTES_DEFINED then 
Wscript.Echo "No routes are defined."
exit do
end if

'Quit if there are no more routes.
if Err.Number = CSS_ERROR_NO_MORE_ITEMS then exit do

'Quit if an empty object was returned.
if IsEmpty(ReplicationRoute) then 
Wscript.Echo "An empty route object was returned."
exit do
end if

'Display the name of the route.
Wscript.Echo ReplicationRoute.Name
Loop

'Release the objects.
set ReplicationRoute  = Nothing
set ReplicationServer = Nothing

See Also

Other Resources

CReplicationServer Class

CReplicationRoute Class

COM Staging Examples