ICertView2::SetRestriction method
Applies to: desktop apps only
The SetRestriction method sets the sorting and qualifying restrictions on a column.
Syntax
HRESULT SetRestriction( [in] LONG ColumnIndex, [in] LONG SeekOperator, [in] LONG SortOrder, [in] const VARIANT *pvarValue );
Parameters
- ColumnIndex [in]
-
A valid column index number for the view or a predefined column specifier. If the ColumnIndex parameter is not negative, this value represents the zero-based index of the column that is receiving the restriction.
If the ColumnIndex parameter is negative, all other parameters are ignored, and this parameter must be one of the following values.
- SeekOperator [in]
-
Specifies the logical operator of the data-query qualifier for the column. This parameter is used with the pvarValue parameter to define the data-query qualifier. This parameter must be set to one of the following values.
Value Meaning - CVR_SEEK_EQ
Equal to
- CVR_SEEK_LE
Less than or equal to
- CVR_SEEK_LT
Less than
- CVR_SEEK_GE
Greater than or equal to
- CVR_SEEK_GT
Greater than
- SortOrder [in]
-
Specifies the sort order for the column. Indexed columns with zero or one restriction can include a sort order of CVR_SORT_ASCEND or CVR_SORT_DESCEND. Nonindexed columns or columns with two or more restrictions must use CVR_SORT_NONE.
Value Meaning - CVR_SORT_ASCEND
Ascending
- CVR_SORT_DESCEND
Descending
- CVR_SORT_NONE
No sort order
- pvarValue [in]
-
Specifies the data query qualifier applied to this column. This parameter, along with the SeekOperator parameter, determines which data is returned to the Certificate Services view.
Return value
VB
If the method succeeds, the method returns S_OK.
If the method fails, it returns an HRESULT value that indicates the error. For a list of common error codes, see Common HRESULT Values.
Remarks
The ICertView object maintains an array of restrictions, allowing each column to contain any number of restrictions. After the column restrictions are established, a call to the ICertView::OpenView method will retrieve the data, with each column's restrictions used as part of the database query.
Before the SetRestriction method is called, it is necessary to establish a connection with the Certificate Service server by calling the ICertView::OpenConnection method.
Examples
// This example restricts the data
// to rows that have RequestIDs greater than five.
// pCertView is a pointer to ICertView.
HRESULT hr;
VARIANT varRest;
LONG nIndex;
BSTR bstrCol = NULL;
// Use one column in the result set.
hr = pCertView->SetResultColumnCount(1);
if (FAILED(hr))
{
printf("Failed SetResultColumnCount - %x\n", hr);
goto error;
}
// Determine the column index for RequestID column.
bstrCol = SysAllocString(TEXT("RequestID"));
hr = pCertView->GetColumnIndex(FALSE, bstrCol, &nIndex);
if (FAILED(hr))
{
printf("Failed GetColumnIndex - %x\n", hr);
goto error;
}
// Place this column into the result set.
pCertView->SetResultColumn(nIndex);
// Set a restriction on this column.
VariantInit(&varRest);
varRest.vt = VT_I4;
varRest.lVal = 5;
// Restrict view to requests with ID greater than 5.
hr = pCertView->SetRestriction(nIndex,
CVR_SEEK_GT,
CVR_SORT_NONE,
&varRest);
if (S_OK != hr)
printf("Failed ICertView::SetRestriction - %x\n", hr);
else
{
// Call OpenView, process rows, release resources, and so on.
// ...
}
error:
// Done processing, clear resources.
VariantClear(&varRest);
if (NULL != bstrCol)
SysFreeString(bstrCol);
Requirements
|
Minimum supported client | None supported |
|---|---|
|
Minimum supported server | Windows Server 2003 |
|
Header |
|
|
Library |
|
|
DLL |
|
|
IID |
IID_ICertView2 is defined as d594b282-8851-4b61-9c66-3edadf848863 |
See also
- ICertView2
- ICertView
- ICertView::OpenConnection
- ICertView::OpenView
- ICertView::SetResultColumn
- IEnumCertViewColumn::IsIndexed
Send comments about this topic to Microsoft
Build date: 3/6/2012