SQL-DMO Collections

SQL-DMO

SQL-DMO

SQL-DMO Collections

Microsoft® Visual Basic® defines a collection as any object containing other objects in a list. For a specific Visual Basic application, a document collection can contain a Microsoft Word document and two Microsoft Excel spreadsheets, in no particular order. SQL-DMO applies a much stricter definition for a collection. A SQL-DMO collection is a container object for SQL-DMO objects of identical type.

For example, the Database object exposes a Tables collection. Each SQL-DMO object referenced from a Tables collection is a Table object, and each Table object exposes the attributes of a specific Microsoft SQL Server™ table. Therefore, the Tables collection of the Database object exposes all defined tables within the SQL Server database. Working with any given Tables collection, you will not find a MergeArticle object or two, or the odd Operator object.

Because SQL-DMO collections are COM objects, they expose properties and methods. All SQL-DMO collections expose the Count property, which reports the number of contained objects. Most collections expose the Add and Remove methods. A collection exposing Add and Remove can be used to create or drop SQL Server components.

Note  To enable more efficient processing, SQL-DMO caches much of the information about SQL Server components referenced by objects maintained in a collection. When component data is cached, administrative activity of another SQL Server session is not visible to the SQL-DMO session. The Refresh method queries the organization server, filling the collection with the most up-to-date component information.