CCustomSession (CustomSess.H)

CustomSess.H contains the declaration and implementation for the OLE DB session object. The data source object creates the session object and represents a conversation between a consumer and provider. Several simultaneous sessions can be open for one data source. The inheritance list for CCustomSession follows:

/////////////////////////////////////////////////////////////////////////
// CCustomSession
class ATL_NO_VTABLE CCustomSession :
   public CComObjectRootEx<CComSingleThreadModel>,
   public IGetDataSourceImpl<CCustomSession>,
   public IOpenRowsetImpl<CCustomSession>,
   public ISessionPropertiesImpl<CCustomSession>,
   public IObjectWithSiteSessionImpl<CCustomSession>,
   public IDBSchemaRowsetImpl<CCustomSession>,
   public IDBCreateCommandImpl<CCustomSession, CCustomCommand>

The session object inherits from IGetDataSource, IOpenRowset, ISessionProperties, and IDBCreateCommand. The IGetDataSource interface allows a session to retrieve the data source that created it. This is useful if you need to get properties from the data source that you created or other information that the data source can provide. The ISessionProperties interface handles all the properties for the session. The IOpenRowset and IDBCreateCommand interfaces are used to do the database work. If the provider supports commands, it implements the IDBCreateCommand interface. It's used to create the command object that can execute commands. The provider always implements the IOpenRowset object. It's used to generate a rowset from a provider. It's a default rowset (for example, "select * from mytable") from a provider.

The wizard also generates three session classes: CCustomSessionColSchema, CCustomSessionPTSchema, and CCustomSessionTRSchema. These sessions are used for schema rowsets. Schema rowsets allow the provider to return metadata to the consumer without the consumer having to execute a query or fetch data. Fetching metadata can be far quicker than finding a provider's capabilities.

The OLE DB specification requires that providers implementing the IDBSchemaRowset interface support three schema rowset types: DBSCHEMA_COLUMNS, DBSCHEMA_PROVIDER_TYPES, and DBSCHEMA_TABLES. The wizard generates implementations for each schema rowset. Each class generated by the wizard contains an Execute method. In this Execute method, you can return data to the provider about which tables, columns, and data types you support. This data is known at compile time.

See also

Provider Wizard-Generated Files