Udostępnij za pośrednictwem


Accessors and Rowsets

To set and retrieve data, OLE DB Templates use an accessor and a rowset through the CAccessorRowset class. This class can handle multiple accessors of different types.

Accessor Types

All accessors derive from CAccessorBase. CAccessorBase provides both parameter and column binding.

The following figure shows the accessor types.

Accessor Classes

Accessor types

  • CAccessor   Use this accessor when you know the structure of the database source at design time. CAccessor statically binds a database record, which contains the buffer, to the data source.

  • CDynamicAccessor   Use this accessor when you do not know the structure of the database at design time. CDynamicAccessor calls IColumnsInfo::GetColumnInfo to get the database column information. It creates and manages an accessor and the buffer.

  • CDynamicParameterAccessor   Use this accessor to handle unknown command types. When you prepare the commands, CDynamicParameterAccessor can get parameter information from the ICommandWithParameters interface, if the provider supports ICommandWithParameters.

  • CDynamicStringAccessor, CDynamicStringAccessorA, and CDynamicStringAccessorW   Use these classes when you have no knowledge of the database schema. CDynamicStringAccessorA retrieves data as ANSI strings; CDynamicStringAccessorW retrieves data as Unicode strings.

  • CManualAccessor   With this class, you can use whatever data types you want if the provider can convert the type. It handles both result columns and command parameters.

The following table summarizes the support in the OLE DB Template accessor types.

Accessor type

Dynamic

Handles params

Buffer

Multiple accessors

CAccessor

No

Yes

User

Yes

CDynamicAccessor

Yes

No

OLE DB Templates

No

CDynamicParameterAccessor

Yes

Yes

OLE DB Templates

No

CDynamicStringAccessor[A,W]

Yes

No

OLE DB Templates

No

CManualAccessor

Yes

Yes

User

Yes

Rowset Types

The OLE DB Templates support three kinds of rowsets (see the preceding figure): single rowsets (implemented by CRowset), bulk rowsets (implemented by CBulkRowset), and array rowsets (implemented by CArrayRowset). Single rowsets fetch a single row handle when MoveNext is called. Bulk rowsets can fetch multiple row handles. Array rowsets are rowsets that can be accessed using array syntax.

The following figure shows the rowset types.

Rowset Classes

RowsetType graphic

Schema rowsets do not access data in the data store but instead access information about the data store, called metadata. Schema rowsets are typically used in situations in which the database structure is not known at compile time and must be obtained at run time.

See Also

Concepts

OLE DB Consumer Templates (C++)