Using SQL-DMO Objects

The core of SQL-DMO is the SQLServer object. For each SQL Server you want to connect to, you create an empty SQLServer object and connect it to a running SQL Server. There are three methods using Microsoft Visual Basic to create SQL-DMO objects (including SQL Server objects). There is only one method to create a SQL-DMO object in Microsoft Visual C++.

After creating a new, empty SQLServer object, you connect that object to a running SQL Server using the Connect method of the SQLServer object. You pass SQL Server name, login identifier, and password parameters to the Connect method. When the Connect method is successful, the SQLServer object is filled with information about the connected SQL Server. The SQLServer object and all objects "under" the SQLServer object (in the SQL-DMO object hierarchy) are now valid and available for use. This availability includes all SQLServer properties (including object properties), all supported SQLServer methods, all SQLServer collections, and all objects "under" SQLServer. SQL-DMO also adds the connected SQLServer object to the application's SQLServer collection.

For more information about using SQL-DMO objects, see the Microsoft SQL Server Programmer's Toolkit documentation in the "Database and Messaging Services" section of the Platform SDK.