Udostępnij za pośrednictwem


Reference Accessors

A reference accessor enables consumers to get rowset data directly from the provider's buffer and enables providers to get input parameter data directly from the consumer's buffer. Consumers cannot use these accessors with output parameters or when setting row data.

Reference accessors require the consumer to have prior knowledge of the provider's buffer layout. The consumer cannot discover this information through OLE DB interfaces at run time. Because of this, reference accessors are designed for use by tightly coupled consumer/provider pairs. Because they allow direct access to the provider's buffers, providers are not required to support them.

To use reference accessors, the layout of the consumer's bindings must exactly match the layout of the provider's buffer. If the provider's buffer does not contain length or status parts, the consumer cannot bind these parts and, in the same manner as the provider, must determine length and whether the data value is NULL.

To use a reference accessor, the consumer passes the handle of the accessor and a pointer to a buffer to the provider. For rowset data, the provider returns a pointer to its internal buffer in the buffer supplied by the consumer. The consumer then dereferences this pointer and reads directly from the provider's buffer. For input parameter data, the consumer's buffer contains a pointer to the buffer that actually contains the data. The provider dereferences this pointer and reads directly from the consumer's other buffer.

The consumer (for rowset data) or provider (for input parameter data) must not write to this buffer, nor can it free this buffer.

For rowset data, the pointer returned by the provider is guaranteed to remain valid until the consumer calls IRowsetChange::SetData, IRowsetChange::DeleteRows, IRowsetRefresh::RefreshVisibleData, IRowsetUpdate::Undo, or IRowsetUpdate::Update for the row; calls IRowset::ReleaseRows for the row and the reference count falls to zero; or releases the rowset. For input parameter data, the pointer is guaranteed to remain valid only until ICommand::Execute returns.

This topic is a part of: