Calling Methods

A method is a function that performs an action using a SQL-DMO object.

Visual Basic

To call a method that takes no parameters, use the following syntax:

[return =] Object.Method

To call a method that takes parameters and doesn't return a value (or to ignore any return value), use the following syntax:

Object.Method [Name1 :=] param1, [Name2 :=] param2, ...

To call a method that takes parameters and returns a value, use the following syntax:

return = Object.Method ( [Name1 :=] param1, [Name2 :=] param2, ... )

The Name items are optional parameter names. If you include parameter names, you can specify the method parameters in any order. If you do not use parameter names, you must specify the method parameters in the required order.

For example:

Dim oQueryResults As SQLOLE.QueryResults
oQueryResults = oSQLServer.ReadErrorLog (0)
C++

To call a method that takes no parameters, use the following syntax:

pObject->Method ( );

To call a method that takes parameters (but no return parameters), use the following syntax:

pObject->Method ( param1, param2, ... );

If the method has a return parameter, you must pass the address of a program variable (use the address of & operator) of the appropriate type as the return parameter. The method will write the return value to your program variable.

To call a method that takes a single return parameter, use the following syntax:

pObject->Method ( &return );

To call a method that takes input parameters (but no optional parameters) and a required or optional return parameter, or a method that takes required and optional input parameters and an optional return parameter, use the following syntax:

pObject->Method ( param1, param2, ..., &return );

To call a method that takes required input parameters, a required return parameter, and optional input parameters, use the following syntax:

pObject->Method ( req_param1, ..., &return, opt_param2, ... );

For example:

LPSQLOLEQUERYRESULTS pQueryResults = NULL;
pSQLServer->ReadErrorLog (&pQueryResults, 0);