SQL-DMO implements collection handling member functions within the parent object of any collection. For example, without the shortcut member functions, the application needing an item from a SQL-DMO collection would:
Using a shortcut member function, the application can:
Shortcut member function naming is consistent, following the rules illustrated in the table below.
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.