Collection Handling

SQL-DMO

SQL-DMO

Collection Handling

SQL-DMO implements collection handling member functions within the parent object of any collection. For example, without the shortcut member functions, the application that requires an item from a SQL-DMO collection would:

  • Get the parent object of the collection.

  • Get a reference on the collection.

  • Use the ItemByName or ItemByOrd member function of the collection to dereference a specific collection item.

Using a shortcut member function, the application can:

  • Get the parent object of the collection.

  • Use the ByName or ByOrd shortcut member function of the parent object to dereference a specific collection item.

Shortcut member function naming is consistent, following the rules illustrated in this table.

Collection implementation Parent implementation
GetItemByName GetObjectByName
GetItemByOrd GetObjectByOrd
RemoveByName RemoveObjectByName
RemoveByOrd RemoveObjectByOrd
Add AddObject
GetCount GetObjectCount

Replace Object in the rule description with the name of the object contained in the collection, as in GetDatabaseByName.

Shortcut member function syntax follows that defined in the SQL-DMO reference for the item member functions used by the collection. For example, the GetItemByName member function of the Database object has the syntax:

HRESULT GetItemByName(SQLDMO_LPCSTR szName,
LPSQLDMODATABASE *ppObj,
SQLDMO_LPCSTR szOwner = NULL);

The GetDatabaseByName member function of the SQLServer object has the syntax:

HRESULT GetDatabaseByName(SQLDMO_LPCSTR szName,
LPSQLDMODATABASE *ppDatabase,
SQLDMO_LPCSTR szOwner = NULL);

SQL-DMO collection support for any specific member function is discussed in detail in documentation for a collection object. Use collection documentation to determine presence of specific collection member functions and shortcut member functions implemented on the parent object.