Find the property group and property ID for the property you want. (See in the OLE DB Programmer's Reference.)
The following example assumes you are trying to get a property from the rowset. The code for using the session or command is similar, but uses a different interface.
Create a CDBPropset object using the property group as the parameter to the constructor. For example:
CDBPropSet propset(DBPROPSET_ROWSET);
Call AddProperty, passing it the Property ID and a value to be assigned to the property. The type of the value depends on the property you are using.
CDBPropSet propset(DBPROPSET_ROWSET);
propset.AddProperty(DBPROP_IRowsetChange, true);
propset.AddProperty(DBPROP_UPDATABILITY,
DBPROPVAL_UP_INSERT | DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_DELETE);
Use the data member m_spUnkSite
to get the pointer to the object that created your object.
CAgentRowset<CMyProviderCommand>* pRowset = (CAgentRowset<CMyProviderCommand>*) pThis;
CComQIPtr<IRowsetInfo, &IID_IRowsetInfo> spRowsetProps = pRowset;
Use the IRowset interface to call GetProperties. Pass the property set as a parameter. Here's the final code:
CAgentRowset<CMyProviderCommand>* pRowset = (CAgentRowset<CMyProviderCommand>*) pThis;
CComQIPtr<IRowsetInfo, &IID_IRowsetInfo> spRowsetProps = pRowset;
set.AddPropertyID(DBPROP_BOOKMARKS);
DBPROPSET* pPropSet = NULL;
ULONG ulPropSet = 0;
HRESULT hr;
if (spRowsetProps)
hr = spRowsetProps->GetProperties(1, &set, &ulPropSet, &pPropSet);
if (pPropSet)
{
CComVariant var = pPropSet->rgProperties[0].vValue;
CoTaskMemFree(pPropSet->rgProperties);
CoTaskMemFree(pPropSet);
if (SUCCEEDED(hr) && (var.boolVal == VARIANT_TRUE))
{
…
}
}