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


 

Chapter 3: Commands

This chapter 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" in this chapter
Command states "Command States" in this chapter
Input and output parameters "Using Parameters" in this chapter
Multiple results "Multiple Results" in this chapter

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 "OLE DB Objects" in Chapter 1, "Overview of 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;
}