Share via


Multiple Results (OLE DB)

When executed, commands return results. A result can be a rowset, a row, 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 Conceptual Programming Models in OLE DB.

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

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, row, 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, one result per command. If the command did not affect any rows, the returned row count for that result is DB_COUNTUNAVAILABLE. 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.

It is provider-specific whether or not to retrieve row counts. When set, DBPROP_SKIPROWCOUNTRESULTS requires a provider that supports multiple results to either return or skip control row count results on calls to IMultipleResults::GetResult.

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.