Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Provides a standard OLE DB rowset implementation without requiring multiple inheritance of many implementation interfaces.
Syntax
template <
class T,
class Storage,
class CreatorClass,
class ArrayType = CAtlArray<Storage>,
class RowClass = CSimpleRow,
class RowsetInterface = IRowsetImpl <T, IRowset>
>
class CRowsetImpl :
public CComObjectRootEx<CreatorClass::_ThreadModel>,
public CRowsetBaseImpl<T, Storage, ArrayType, RowsetInterface>,
public IRowsetInfoImpl<T, CreatorClass::_PropClass>
Parameters
T
The user's class that derives from CRowsetImpl.
Storage
The user record class.
CreatorClass
The class that contains properties for the rowset; typically the command.
ArrayType
The class that will act as storage for the rowset's data. This parameter defaults to CAtlArray, but it can be any class that supports the required functionality.
Requirements
Header: atldb.h
Members
Methods
| Name | Description |
|---|---|
| NameFromDBID | Extracts a string from a DBID and copies it to the bstr passed in. |
| SetCommandText | Validates and stores the DBIDs in the two strings (m_strCommandText and m_strIndexText). |
Overridable Methods
| Name | Description |
|---|---|
| GetColumnInfo | Retrieves column information for a particular client request. |
| GetCommandFromID | Checks to see if either or both parameters contain string values, and if so, copies the string values to the data members m_strCommandText and m_strIndexText. |
| ValidateCommandID | Checks to see if either or both DBIDs contain string values, and if so, copies them to its data members m_strCommandText and m_strIndexText. |
Data Members
| Name | Description |
|---|---|
| m_rgRowData | By default, a CAtlArray that templatizes on the user record template argument to CRowsetImpl. Another array type class can be used by changing the ArrayType template argument to CRowsetImpl. |
| m_strCommandText | Contains the rowset's initial command. |
| m_strIndexText | Contains the rowset's initial index. |
Remarks
CRowsetImpl provides overrides in the form of static upcasts. The methods control the manner in which a given rowset will validate command text. You can create your own CRowsetImpl-style class by making your implementation interfaces multiple-inherited. The only method for which you must provide implementation is Execute. Depending on what type of rowset you are creating, the creator methods will expect different signatures for Execute. For example, if you are using a CRowsetImpl-derived class to implement a schema rowset, the Execute method will have the following signature:
HRESULT Execute(LONG* pcRows, ULONG cRestrictions, const VARIANT* rgRestrictions)
If you are creating a CRowsetImpl-derived class to implement a command or session's rowset, the Execute method will have the following signature:
HRESULT Execute(LONG* pcRows, DBPARAMS* pParams)
To implement any of the CRowsetImpl-derived Execute methods, you must populate your internal data buffers (m_rgRowData).
CRowsetImpl::NameFromDBID
Extracts a string from a DBID and copies it to the bstr passed in.
Syntax
HRESULT CRowsetBaseImpl::NameFromDBID(DBID* pDBID,
CComBSTR& bstr,
bool bIndex);
Parameters
pDBID
[in] A pointer to the DBID from which to extract a string.
bstr
[in] A CComBSTR reference to place a copy of the DBID string.
bIndex
[in] true if an index DBID; false if a table DBID.
Return Value
A standard HRESULT. Depending on whether the DBID is a table or an index (denoted by bIndex), the method will either return DB_E_NOINDEX or DB_E_NOTABLE.
Remarks
This method is called by the CRowsetImpl implementations of ValidateCommandID and GetCommandFromID.
CRowsetImpl::SetCommandText
Validates and stores the DBIDs in the two strings (m_strCommandText and m_strIndexText).
Syntax
HRESULT CRowsetBaseImpl::SetCommandText(DBID* pTableID,
DBID* pIndexID);
Parameters
pTableID
[in] A pointer to the DBID representing the table ID.
pIndexID
[in] A pointer to the DBID representing the index ID.
Return Value
A standard HRESULT.
Remarks
The SetCommentText method is called by CreateRowset, a static templatized method of IOpenRowsetImpl.
This method delegates its work by calling ValidateCommandID and GetCommandFromID through an upcasted pointer.
CRowsetImpl::GetColumnInfo
Retrieves column information for a particular client request.
Syntax
static ATLCOLUMNINFO* CRowsetBaseImpl::GetColumnInfo(T* pv,
ULONG* pcCols);
Parameters
pv
[in] A pointer to the user's CRowsetImpl derived class.
pcCols
[in] A pointer (output) to the number of columns returned.
Return Value
A pointer to a static ATLCOLUMNINFO structure.
Remarks
This method is an advanced override.
This method is called by several base implementation classes to retrieve column information for a particular client request. Usually, this method would be called by IColumnsInfoImpl. If you override this method, you must place a version of the method in your CRowsetImpl-derived class. Because the method may be placed in a non-templatized class, you must change pv to the appropriate CRowsetImpl-derived class.
The following example demonstrates GetColumnInfo usage. In this example, CMyRowset is a CRowsetImpl-derived class. In order to override GetColumnInfo for all instances of this class, place the following method in the CMyRowset class definition:
static ATLCOLUMNINFO* GetColumnInfo(CCustomRowset* pRowset, DBORDINAL* pcCols)
{
// Add your implementation here and/or call the base class
return CRowsetImpl::GetColumnInfo(pRowset, pcCols);
}
CRowsetImpl::GetCommandFromID
Checks to see if either or both parameters contain string values, and if so, copies the string values to the data members m_strCommandText and m_strIndexText.
Syntax
HRESULT CRowsetBaseImpl::GetCommandFromID(DBID* pTableID,
DBID* pIndexID);
Parameters
pTableID
[in] A pointer to the DBID representing the Table ID.
pIndexID
[in] A pointer to the DBID representing the Index ID.
Return Value
A standard HRESULT.
Remarks
This method is called through a static upcast by CRowsetImpl to populate the data members m_strCommandText and m_strIndexText. By default, this method checks to see if either or both parameters contain string values. If they contain string values, this method copies the string values to the data members. By placing a method with this signature in your CRowsetImpl-derived class, your method will be called instead of the base implementation.
CRowsetImpl::ValidateCommandID
Checks to see if either or both DBIDs contain string values, and if so, copies them to its data members m_strCommandText and m_strIndexText.
Syntax
HRESULT CRowsetBaseImpl::ValidateCommandID(DBID* pTableID,
DBID* pIndexID);
Parameters
pTableID
[in] A pointer to the DBID representing the table ID.
pIndexID
[in] A pointer to the DBID representing the index ID.
Return Value
A standard HRESULT.
Remarks
This method is called through a static upcast by CRowsetImpl to populate its data members m_strCommandText and m_strIndexText. By default, this method checks to see if either or both DBIDs contain string values, and if so, copies them to its data members. By placing a method with this signature in your CRowsetImpl-derived class, your method will be called instead of the base implementation.
CRowsetImpl::m_rgRowData
By default, a CAtlArray that templatizes on the user record template argument to CRowsetImpl.
Syntax
ArrayType CRowsetBaseImpl::m_rgRowData;
Remarks
ArrayType is a template parameter to CRowsetImpl.
CRowsetImpl::m_strCommandText
Contains the rowset's initial command.
Syntax
CComBSTR CRowsetBaseImpl::m_strCommandText;
CRowsetImpl::m_strIndexText
Contains the rowset's initial index.
Syntax
CComBSTR CRowsetBaseImpl::m_strIndexText;