Connecting the SQLServer Object

After creating a new, empty SQLServer object, you connect that object to a running SQL Server using the Connect method of the new SQLServer object. You pass the following parameters to the Connect method:

  1. SQL Server name
  2. Login ID
  3. Password

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 includes the following:

SQL-DMO also adds the connected SQLServer object to the Application.SQLServers collection.

SQL-DMO retrieves information from SQL Server as you request it by using the SQLServer objects. SQL-DMO maintains this SQL Server information in a cache stored in client memory. SQL-DMO improves performance by using this cached information to minimize SQL Server queries. The cache is contained in the collection objects, and you can use the Refresh method to update the cache with current values from SQL Server.

Visual Basic

You can call the Connect method using Visual Basic procedure syntax. For example:

oSQLServer.Connect "myserver", "mylogin", "mypassword"

You can also call the Connect method using Visual Basic function syntax. For example:

Call oSQLServer.Connect ("myserver", "mylogin", "mypassword")
C++

Call the Connect method. For example:

hr = pSQLServer->Connect (TEXT("myserver"),
    TEXT("mylogin"),
    TEXT("mypassword"));