An accessor is a collection of bindings. Each binding associates, or binds, a single column or parameter to the consumer's buffer. You can bind columns and output parameters more than once in a single accessor, but input parameters only once in a single accessor. It is usually a consumer programming error to bind a column more than once in a single accessor and then use that accessor to set the value of the column, such as with IRowsetChange::SetData.
Each binding contains information about the consumer's buffer. The most notable information is the ordinal of the column or parameter to which the binding applies, what is bound (the data value, its length, and its status), the offsets in the buffer to each of these parts, and the length and type of the data value as it exists in the consumer's buffer. For more information, see "Data Parts," earlier in this chapter, and "DBBINDING Structures" later in this chapter.
For example, the following figure shows a consumer's buffer containing 10 bytes for a string, two unused bytes to properly align the string's status and length values, four bytes for the string's status, four bytes for the string's length, two unused bytes to properly align the integer's status value, two bytes for a two-byte integer, and four bytes for the integer's status. It also shows the main binding information used to bind the string to column 1 and the integer to column 2.
Main binding information as shown in a consumer’s buffer
Element | String binding | Integer binding |
Ordinal | 1 | 2 |
Bound parts | DBPART_VALUE | DBPART_LENGTH | DBPART_STATUS |
DBPART_VALUE | DBPART_STATUS |
Offset to data value | 0 | 22 |
Offset to status | 12 | 24 |
Offset to length | 16 | N/A |
Data type | DBTYPE_STR | DBTYPE_I2 |
Buffer length | 10 | 2 |
When getting data, the provider uses the information in each binding to determine where and how to retrieve data from the consumer's buffer. When setting data, the provider uses the information in each binding to determine where and how to return data in the consumer's buffer.