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.
Make sure you really need dynamic column binding. You may need it because:
Your rowset columns are not defined at compile time, or
You support an element such as bookmarks that adds columns.
To implement dynamic column binding:
Remove any PROVIDER_COLUMN_MAPs from your code.
In the user record (your structure), add the following declaration:
static ATLCOLUMNINFO* _GetColumnInfo(void* pThis, ULONG* pcCols);
Implement the _GetColumnInfo function. This function lays out how the information is stored. You may need to get properties or other information for this function. You may want to create a macro, similar to the COLUMN_ENTRY macro, to add your own information.
The following example shows a _GetColumnInfo function.
// Check the property flag for bookmarks, if it is set, set the zero // ordinal entry in the column map with the bookmark information. CAgentRowset* pRowset = (CAgentRowset*) pThis; CComQIPtr<IRowsetInfo, &IID_IRowsetInfo> spRowsetProps = pRowset; CDBPropIDSet set(DBPROPSET_ROWSET); 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)) { ADD_COLUMN_ENTRY_EX(ulCols, OLESTR("Bookmark"), 0, sizeof(DWORD), DBTYPE_BYTES, 0, 0, GUID_NULL, CAgentMan, dwBookmark, DBCOLUMNFLAGS_ISBOOKMARK) ulCols++; } } // Next set the other columns up. ADD_COLUMN_ENTRY(ulCols, OLESTR("Command"), 1, 256, DBTYPE_STR, 0xFF, 0xFF, GUID_NULL, CAgentMan, szCommand) ulCols++; ADD_COLUMN_ENTRY(ulCols, OLESTR("Text"), 2, 256, DBTYPE_STR, 0xFF, 0xFF, GUID_NULL, CAgentMan, szText) ulCols++; ADD_COLUMN_ENTRY(ulCols, OLESTR("Command2"), 3, 256, DBTYPE_STR, 0xFF, 0xFF, GUID_NULL, CAgentMan, szCommand2) ulCols++; ADD_COLUMN_ENTRY(ulCols, OLESTR("Text2"), 4, 256, DBTYPE_STR, 0xFF, 0xFF, GUID_NULL, CAgentMan, szText2) ulCols++; if (pcCols != NULL) *pcCols = ulCols; return _rgColumns; }