共用方式為


Commands (OLE DB)

This section discusses the use and states of command objects, processing multiple result sets, binding input parameters and using output parameters, and the use of rowset properties in command objects. Commands can be in one of four states: Initial, Unprepared, Prepared, or Executed. Parameters can be used with commands to bind to consumer variables at execution time. When executed, a command returns either a single result, which can be either a rowset object or a row count, or multiple results, which must be returned in a multiple results object.

For more information on

Go to

Using commands

Using Commands

Command states

Command States

Input and output parameters

Using Parameters

Multiple results

Multiple Results (OLE DB)

A command object is used to execute a provider-specific text command, such as an SQL statement. Text commands are expressed in a provider-specific language ? usually SQL-92 ? and are generally used for creating a rowset ? for example, executing an SQL SELECT statement.

Providers are not required to support commands. In general, providers built on top of a DBMS, such as an SQL DBMS, support commands, and providers built on top of a simple data structure, such as a file or an array of data in an application, do not support commands.

The command object cotype is defined as follows. For more information about cotypes, see Conceptual Programming Models in OLE DB.

CoType TCommand {
   [mandatory]   interface IAccessor;
   [mandatory]   interface IColumnsInfo;
   [mandatory]   interface ICommand;
   [mandatory]   interface ICommandProperties;
   [mandatory]   interface ICommandText;
   [mandatory]   interface IConvertType;
   [optional]    interface IColumnsRowset;
   [optional]    interface ICommandPersist;
   [optional]    interface ICommandPrepare;
   [optional]    interface ICommandWithParameters;
   [optional]    interface ISupportErrorInfo;
   [optional]    interface ICommandStream;
}

This section contains the following subsections: