Using SQL-DMO Objects

This chapter provides instructions for using SQL-DMO objects in your Visual Basic and C++ programs. The SQL-DMO custom component provides 32-bit COM objects which can be used from 32-bit Visual Basic programs and 32-bit C++ programs.

The SQL-DMO component name or application name is SQLOLE.

For brevity, the sample code included in this chapter does not check for success or handle errors.

Visual Basic

Visual Basic is an OLE Automation controller. You can use Visual Basic to write programs that use SQL-DMO objects. The steps required to use SQL-DMO objects in a Visual Basic program are:

  1. Include the SQL-DMO type library.
  2. Create a SQLServer object.
  3. Connect the SQLServer object.
  4. Use the SQLServer object and other contained objects.
  5. Release the SQLServer object.

Use a period (.) to separate an object variable from the properties, methods and collections of that object.

C++

You can use C++ and OLE functions to write programs that use SQL-DMO objects. The steps required to use SQL-DMO objects in a C++ program are:

  1. Include the SQL-DMO and OLE header files, and link to OLE libraries.
  2. Initialize the COM library.
  3. Create a SQLServer object.
  4. Connect the SQLServer object.
  5. Use the SQLServer object and other contained objects.
  6. Release the SQLServer object.
  7. Uninitialize the COM library.

Use the member-selection operator (->) to separate a "pointer to an object" variable from the property, method, and collection functions.