Condividi tramite


IAccessor

IAccessor provides methods for accessor management. For information about accessors, see the section about Accessors in Getting and Setting Data.

When to Implement

All rowsets and commands must implement IAccessor.

Accessors can be used for rowset data, parameter data, or both. Row and parameter accessors can be created on a command. The consumer must verify that row accessors created on the command are still valid following a change to the command. Accessors created on a command are not persisted with that command. Accessors created on a command are inherited by the rowsets it creates. To the consumer, it appears as if each accessor has been copied from the command to the rowset: The bindings, flags, and handle of each accessor are the same on both the rowset and the command.

Accessors created on a rowset are available only to that rowset. They are not available to the command that created the rowset or other rowsets created by the command.

When an accessor is created on a rowset or command, it has a reference count of 1. If a rowset inherits an accessor from a command, the accessor has a reference count of 1 on the rowset, regardless of the reference count of the same accessor on the command. Calls to IAccessor::AddRefAccessor increment the reference count of the accessor, and calls to IAccessor::ReleaseAccessor decrement the reference count of the accessor. When the reference count of an accessor reaches zero, the accessor and all resources used by that accessor are released. If the accessor is created on a command and inherited by the rowset, releasing the accessor on the command does not affect the "copy" of the accessor on the rowset and vice versa.

When the reference count of a rowset reaches zero, all accessors created on that rowset or inherited from the command that created it are released completely. If any accessors were inherited from the command, the "copies" of these parent accessors on the command are not affected.

When the reference count of a command reaches zero, all accessors created on the command are released completely. If any rowsets inherited accessors from the command, the "copies" of these accessors on the rowsets are not affected.

When to Call

To create an accessor, a consumer calls IAccessor::CreateAccessor. The consumer may create and release accessors at any time while the rowset or command remains in existence. When one thread of a consumer shares an accessor with another thread, it calls IAccessor::AddRefAccessor to increment the reference count of that accessor.

When the consumer is done with a rowset, it calls IAccessor::ReleaseAccessor to release any accessors on the rowset, including accessors inherited from the command. When the consumer is done with a command, it calls IAccessor::ReleaseAccessor to release any accessors created on the command. In either case, the consumer must call IAccessor::ReleaseAccessor once for each reference count on the accessor.

Method

Description

AddRefAccessor

Adds a reference count to an existing accessor.

CreateAccessor

Creates an accessor from a set of bindings.

GetBindings

Returns the bindings in an accessor.

ReleaseAccessor

Releases an accessor.

This topic is a part of: