共用方式為


How to: Retrieve Rows Using Bookmarks (OLE DB)

新增: 2006 年 4 月 14 日

The consumer sets the dwFlag field value of the binding structure to DBCOLUMNSINFO_ISBOOKMARK to indicate that the column is used as bookmark. The consumer also sets the rowset property DBPROP_BOOKMARKS to VARIANT_TRUE. This allows column 0 to be present in the rowset. IRowsetLocate::GetRowsAt is then used to fetch rows starting with the row specified an offset from a bookmark.

A complete sample shows how to fetch rows using a bookmark. The complete sample code is in the file GetRowsUsingBookmark.cpp. You can download an archive containing the sample from the SQL Server Downloads page on MSDN. In this sample, the fifth row is retrieved from the result set produced from the execution of a SELECT statement.

This sample was developed using Microsoft Visual C++ 2005.

ms403301.security(zh-tw,SQL.90).gif安全性注意事項:
When possible, use Windows Authentication. If Windows Authentication is not available, prompt users to enter their credentials at run time. Avoid storing credentials in a file. If you must persist credentials, you should encrypt them with the Win32 crypto API.

To retrieve rows using bookmarks

  1. Establish a connection to the data source.

  2. Set the rowset DBPROP_IRowsetLocate property to VARIANT_TRUE.

  3. Execute the command.

  4. Set the dwFlag field of the binding structure to DBCOLUMNSINFO_ISBOOKMARK flag for the column that will be used as a bookmark.

  5. Use IRowsetLocate::GetRowsAt to fetch rows, starting with the row specified by an offset from the bookmark.

請參閱

概念

Using Bookmarks (SQL Native Client)

說明及資訊

取得 SQL Server 2005 協助