Removing an Existing Object from a Collection

Removing an existing SQL-DMO object from a collection drops that SQL Server object.

Visual Basic

You remove an existing object from a collection by specifying one of the following:

using the following syntax:

Objects.Remove ( {strName | lOrdinal} )

You can also remove an existing object directly using the following syntax:

Object.Remove

C++

You remove an object from a collection by name or by ordinal value (the first ordinal value is number 0) using the following syntax:

pObjects->RemoveByName ( strName );

pObjects->RemoveByOrd ( lOrdinal );

You can also use the RemoveObjectByName or RemoveObjectByOrd "shortcut" functions of the parent object to remove an existing object by name or by ordinal value (0-based) using the following syntax:

pParent->RemoveObjectByName ( strName );

pParent->RemoveObjectByOrd ( lOrdinal );