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.

Multiple results:

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 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.