Value

The value is the actual value of the data. For example, the value of a column containing last names might be "Smith." Unless the type indicator of the data is DBTYPE_BSTR or is combined with DBTYPE_BYREF, DBTYPE_ARRAY, or DBTYPE_VECTOR, the data is stored directly at the offset specified in the binding. Sufficient space must be allocated for the data.

For example, if the type indicator is DBTYPE_I2, a two-byte integer is stored at the specified offset and two bytes must be allocated at that offset. If the type indicator is DBTYPE_STR, an ANSI string is stored at the specified offset. If the length of the string in bytes is longer than the number of bytes specified at the offset in the cbMaxLen element of the DBBINDING structure, then the string is truncated.

If the type indicator is DBTYPE_BSTR or is combined with DBTYPE_BYREF, DBTYPE_ARRAY, or DBTYPE_VECTOR, then a pointer to the data is stored at the offset specified in the binding and the data is stored in separately allocated memory. For example, if the type indicator is DBTYPE_BSTR, a pointer to a BSTR is stored at the specified offset and sizeof(BSTR) bytes must be allocated at that offset; the BSTR itself is stored in memory allocated with one of the Automation string allocation functions. If the type indicator is DBTYPE_STR | DBTYPE_BYREF, a pointer to an ANSI string is stored at the specified offset and sizeof(char *) bytes must be allocated at that offset; the string itself is stored in separately allocated memory. For more information, see "Type Indicators" in Appendix A.

The only exception to these rules is when a reference accessor is used, in which case the value is a pointer to the provider's buffer for rowset data, or a pointer to the consumer's buffer for input parameter data. For more information, see "Reference Accessors" later in this chapter.