OLE DB Programmer's Reference |
Compares two bookmarks.
HRESULT Compare ( HCHAPTER hChapter, DBBKMARK cbBookmark1, const BYTE *pBookmark1, DBBKMARK cbBookmark2, const BYTE *pBookmark2, DBCOMPARE *pComparison);
Parameters
When comparing literal bookmarks and hChapter is DB_NULL_HCHAPTER, IRowsetLocate::Compare must return the same ordering as an arithmetic comparison. If hChapter is not DB_NULL_HCHAPTER, IRowsetLocate::Compare must reflect the ordering within that chapter. Also, the row designated by the special bookmarks DBBMK_FIRST or DBBMK_LAST depends on the chapter.
Value | Description |
---|---|
DBCOMPARE_LT | The first bookmark is before the second. |
DBCOMPARE_EQ | The two bookmarks are equal. |
DBCOMPARE_GT | The first bookmark is after the second. |
DBCOMPARE_NE | The bookmarks are not equal and not ordered. |
DBCOMPARE_NOTCOMPARABLE | The two bookmarks cannot be compared. When to return DBCOMPARE_NOTCOMPARABLE:
|
Return Code
pBookmark1, pBookmark2, or pComparison was a null pointer.
Note Consumers should attempt to use only bookmarks that they have received from the provider. The provider is guaranteed to handle only bookmarks it gives out in a predictable manner. Attempting to use a random value as a bookmark is undefined; the provider may return DB_E_BADBOOKMARK, may return an unexpected row, or may terminate abnormally.
The rowset was single-chaptered, and the specified chapter was not the currently open chapter. The consumer must use the currently open chapter or release the currently open chapter before specifying a new chapter.
Comments
This method makes no logical change to the state of the object.
If bookmarks are ordered, they can be compared to determine the relative position of their associated rows in the rowset. The DBPROP_ORDEREDBOOKMARKS property indicates whether bookmarks are ordered. If bookmarks are not ordered, the returned comparison value will be DBCOMPARE_EQ or DBCOMPARE_NE. If bookmarks are ordered, the returned comparison value will be DBCOMPARE_LT, DBCOMPARE_EQ, or DBCOMPARE_GT. The command that creates the rowset does not have to have an ordered text command, such as an SQL statement containing an ORDER BY clause, to have ordered bookmarks.
IRowsetLocate::Compare can compare any valid bookmarks. The consumer is not required to have permission to read the corresponding rows nor are the rows even required to existfor example, they might have been deleted.
If the DBPROP_LITERALBOOKMARKS property is VARIANT_TRUE, consumers can directly compare values.
Specifying the bookmark DBBMK_FIRST or DBBMK_LAST returns DBCOMPARE_EQ when compared with itself and DBCOMPARE_NE when compared with any other bookmark.
IRowsetIdentity::IsSameRow | IRowsetLocate::Hash
1998-2001 Microsoft Corporation. All rights reserved.