Export (0) Print
Expand All

CMyProviderSession (MyProviderSess.H)

MyProviderSess.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 CMyProviderSession follows:

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

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 is used to create the command object that can execute commands. The provider always implements the IOpenRowset object. It is used to generate a simple rowset from a provider. It is a default rowset (for example, "select * from mytable") from a provider.

The wizard also generates three session classes: CMyProviderSessionColSchema, CMyProviderSessionPTSchema, and CMyProviderSessionTRSchema. 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 discovering a providers 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 usually known at compile time.

Community Additions

ADD
Show:
© 2015 Microsoft