A binding associates a single column or parameter to the consumer's buffer, and contains information about the buffer.
The DBBINDING structure describes a single binding.
typedef struct tagDBBINDING {
ULONG iOrdinal;
ULONG obValue;
ULONG obLength;
ULONG obStatus;
ITypeInfo * pTypeInfo;
DBOBJECT * pObject;
DBBINDEXT * pBindExt;
DBPART dwPart;
DBMEMOWNER dwMemOwner;
DBPARAMIO eParamIO;
ULONG cbMaxLen;
DWORD dwFlags;
DBTYPE wType;
BYTE bPrecision;
BYTE bScale;
} DBBINDING;
The elements of this structure are used as follows.
Element | Description |
iOrdinal | The ordinal of the column or parameter to which the binding applies. Column ordinals are fixed for the lifetime of the rowset. The self bookmark column is column 0 and other columns start with column 1. To retrieve column ordinals, consumers call IColumnsInfo::GetColumnInfo, IColumnsRowset::GetColumnsRowset, or IColumnsInfo::MapColumnIDs. If the rowset is generated from a command, the column ordinals returned by GetColumnInfo or GetColumnsRowset on the rowset must match the column ordinals returned by the same methods on the command. Parameter ordinals are determined from the text command. The first parameter is parameter one. To retrieve parameter ordinals, consumers call ICommandWithParameters::GetParameterInfo. |
obValue | The offset in bytes in the consumer's buffer to the value part. obValue is ignored unless the DBPART_VALUE bit is set in dwPart. For more information about the value part, see "Value" earlier in this chapter. This offset must be properly aligned for the processor architecture of the consumer's machine. If data is improperly aligned, consumers can expect alignment faults to occur when getting and setting data values. Consumers should use addresses that are multiples of the size of the data type. For example, if wType is DBTYPE_I4, the value part should be DWORD aligned. |
obLength | The offset in bytes in the consumer's buffer to the length part. obLength is ignored unless the DBPART_LENGTH bit is set in dwPart. For more information about the length part, see "Length" earlier in this chapter. The length itself is a ULONG. This offset must be properly aligned for the processor architecture of the consumer's machine; that is, it should be a multiple of sizeof(ULONG). If it is improperly aligned, consumers can expect alignment faults when getting and setting length values. |
obStatus | The offset in bytes in the consumer's buffer to the status part. obStatus is ignored unless the DBPART_STATUS bit is set in dwPart. For more information about the status part, see "Status" earlier in this chapter. The status part itself is a DBSTATUS value, which is a DWORD. This offset must be properly aligned for the processor architecture of the consumer's machine; that is, it should be a multiple of sizeof(DWORD). If it is improperly aligned, consumers can expect alignment faults when getting and setting status values. |
pTypeInfo | Reserved for future use. Consumers should set pTypeInfo to a null pointer. |
pObject | Pointer to a DBOBJECT structure. This structure describes how OLE objects in columns or parameters should be accessed.
The elements of this structure are used as follows:
The storage mode flags are defined by the Structured Storage model in OLE. These are:
pObject is ignored unless the DBPART_VALUE bit is set in dwPart and wType is DBTYPE_IUNKNOWN. If neither of these conditions is true, it should be set to a null pointer. Note Consumers should not set wType to DBTYPE_IUNKNOWN and the DBPART_VALUE bit in dwPart without specifying a non-null value for pObject. However, providers can assume in this case that the interface to be bound is IID_IUnknown. |
pBindExt | The DBBINDEXT structure can be used for future extensions to the binding structure. pBindExt is reserved for future use and consumers should set it to a null pointer.
|
dwPart | Specifies which buffer parts are to be bound to the column or parameter. It is one or more DBPARTENUM values combined; these values have the following meaning:
|
dwMemOwner | For bindings in row accessors, specifies who owns memory allocated by the provider for a column and for which a pointer is returned to the consumer. For example, when wType is DBTYPE_BYREF | DBTYPE_STR, the provider allocates memory for the string and returns a pointer to the string to the consumer; dwMemOwner specifies whether the consumer or provider owns this memory. The provider ignores this when setting rowset data. The following is a description of each of these values:
For bindings in row accessors, consumer-owned memory must be used unless wType is DBTYPE_BSTR, X | DBTYPE_BYREF, X | DBTYPE_ARRAY, or X | DBTYPE_VECTOR, in which case either consumer- or provider-owned memory can be used. However, provider-owned memory cannot be used if IColumnsInfo::GetColumnInfo returns the DBCOLUMNFLAGS_ISLONG for the column. Consumers can mix bindings for provider- and consumer-owned memory in the same accessor. For bindings in parameter accessors, consumer-owned memory must always be used. dwMemOwner is ignored in reference accessors. All providers must support binding to client-owned memory. Providers support provider-owned memory only if they can efficiently return a pointer to a cached value. Providers are not required to support binding deferred columns to provider-owned memory. |
eParamIO | For parameter accessors, eParamIO specifies whether the parameter with which the binding is associated is an input, input/output, or output parameter. Providers support only those parameter I/O types that are supported by their underlying data source. eParamIO is one or more DBPARAMIOENUM values combined. These values have the following meaning:
For row accessors, eParamIO is ignored. |
cbMaxLen | The length in bytes of the consumer's data structure allocated for the data value. That is, it is the number of bytes allocated at offset obValue for the data value. cbMaxLen is ignored unless the DBPART_VALUE bit is set in dwPart and the data value stored at that location is of variable length. For information about variable-length data types, see "Fixed- and Variable-Length Data Types" in Chapter 10. cbMaxLen is used as follows:
|
dwFlags | dwFlags specifies information about how data is returned. The following flag is recognized:
The provider should format the returned data in HTML. If the provider does not support HTML formatting, the bit is ignored and regular text is returned. The provider will not be able to use an accessor created with the HTML flag to set data. |
wType | The indicator of the data type of the value part of the buffer. For more information about type indicators, see "Type Indicators" in Appendix A. This type forms an implied conversion between the buffer type and the type of the column or parameter. For information about conversions providers are required to support, see "Data Type Conversion" in Chapter 10. |
bPrecision | The maximum precision to use when getting data and wType is DBTYPE_NUMERIC. This is ignored when setting data, wType is not DBTYPE_NUMERIC, or the DBPART_VALUE bit is not set in dwPart. For more information, see "Conversions Involving DBTYPE_NUMERIC or DBTYPE_DECIMAL" in Appendix A. |
bScale | The scale to use when getting data and wType is DBTYPE_NUMERIC or DBTYPE_DECIMAL. This is ignored when setting data, wType is not DBTYPE_NUMERIC or DBTYPE_DECIMAL, or the DBPART_VALUE bit is not set in dwPart. For more information, see "Conversions Involving DBTYPE_NUMERIC or DBTYPE_DECIMAL" in Appendix A. |
Note The offsets specified in obValue, obLength, and obStatus must not point to overlapping areas of memory. The provider is not required to check if this condition occurs, and consumers must be careful to avoid this condition when constructing bindings.