MDAC 2.5 SDK - OLE DB Programmer's Reference
Chapter 3: Commands


 

Multiple Results

When executed, commands return results. A result can be either a rowset or a row count, which is the number of rows affected by a command that updates, deletes, or inserts rows. Commands can return multiple results if the command text comprises multiple, separate text commands—such as a batch of SQL statements—or if more than one set of parameters is passed to a command.

The multiple results object cotype is defined as follows. For more information about cotypes, see "OLE DB Objects" in Chapter 1, "Overview of OLE DB."

CoType TMultipleResults {
   [mandatory]   interface IMultipleResults;
   [optional]    interface ISupportErrorInfo;
}

To retrieve multiple results, consumers use multiple results objects. Providers are not required to support these, however. The DBPROP_MULTIPLERESULTS property in the Data Source Information property group specifies whether a provider supports multiple results objects.

To create a multiple results object, the consumer sets the DBPROP_IMultipleResults property on the command and requests the IMultipleResults interface when it calls ICommand::Execute. Execute returns an interface pointer on the multiple results object to the consumer.

To retrieve each rowset or row count created by the command, the consumer calls IMultipleResults::GetResult. GetResult returns results in the order they were specified in the command text. If the current result is a rowset, some providers require the consumer to release the rowset before GetResult returns the next result. The DBPROP_MULTIPLERESULTS property specifies whether this is required.

Rowsets returned by IMultipleResults::GetResult have the properties set as defined by the command that created the multiple results object. These properties are identical for each result set. There is no way to set different properties for results of a multiple result.