Referencing a Property in Your Provider

JavaScript EditorDhtml editor     Free javascript download 



Main Page

Find the property group and property ID for the property you want. For more information, see OLE DB Properties in the OLE DB Programmer's Reference.

The following example assumes that 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:

В CopyCode imageCopy Code
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.

В CopyCode imageCopy Code
CDBPropSet propset(DBPROPSET_ROWSET);
propset.AddProperty(DBPROP_IRowsetChange, true);
propset.AddProperty(DBPROP_UPDATABILITY,
DBPROPVAL_UP_INSERT | DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_DELETE);

Use the IRowset interface to call GetProperties. Pass the property set as a parameter. Here is the final code:

В CopyCode imageCopy Code
CAgentRowset<CMyProviderCommand>* pRowset = (CAgentRowset<CMyProviderCommand>*) pThis;

CComQIPtr<IRowsetInfo, &IID_IRowsetInfo> spRowsetProps = pRowset;

DBPROPIDSET set;
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))
   {
      ...  // Use property here
   }
}

Expand imageSee Also



JavaScript EditorDhtml editor     Free javascript download