This chapter discusses how data is transferred between the consumer and provider. A consumer is any piece of system or application code that consumes an OLE DB interface. This includes OLE DB components themselves. A provider is any software component that exposes an OLE DB interface. The three parts of data—value, length of the value, and its status—are discussed. Accessors, which are a collection of information that describes how data is stored in the consumer's buffer, are presented, along with a special type called the reference accessor. Defined another way, an accessor is a collection of bindings: Each binding associates a single column or parameter to the consumer's buffer. Bindings and their structures as exposed by DBBINDING are discussed. Obviously an important aspect of data transfer for the consumer is memory management. This, along with procedures for data transfer, completes the topic of “Getting and Setting Data.”
For more information on | Go to |
Consumers and providers | “Consumers and Providers” in Chapter 1, “Overview of OLE DB” |
OLE DB components | “OLE DB Components” in Chapter 1, “Overview of OLE DB” |
Parts of data | “Data Parts” in this chapter |
Status of a data value | “Status” in this chapter |
Accessors | “Accessors” in this chapter |
Reference accessors | “Reference Accessors” in this chapter |
Bindings and their structures | “Bindings” in this chapter |
Memory management in data transfer | “Memory Management” in this chapter |
Data transfer procedures | “Data Transfer Procedures” in this chapter |
Data refers collectively to parameter data and rowset data. Parameter data is the data used for parameters in commands. For example, in the text command SELECT * FROM MyTable WHERE Name = ?, the question mark represents a parameter and the consumer sends data for this parameter to the provider when it executes the command. Rowset data is the data returned in a rowset, such as the rowset generated by executing the previous command, and key column values passed to an index rowset when setting the index range or seeking for a key value.
Data is stored in both the consumer and the provider. The consumer stores data in a buffer. A binding associates, or binds, a single column or parameter to the consumer's buffer, and a group of bindings is gathered together in an accessor. When transferring data, the handle to the accessor and the pointer to the buffer are passed to the provider. In the provider, data is stored in a provider-specific way. For example, it may be placed in a structure, such as the rowset's copy of a row, or passed directly through to the data source.
The provider actually transfers the data from consumer to provider and provider to consumer. Getting data is defined as transferring data from the provider to the consumer, as when getting rowset data with IRowset::GetData or getting output parameter data with ICommand::Execute. Setting data is defined as transferring data from the consumer to the provider, as when setting rowset data with IRowsetChange::SetData, key values with IRowsetIndex::SetRange, or input parameter data with Execute.