共用方式為


CDaoRecordset::Find

virtual BOOL Find( long lFindType**, LPCTSTRlpszFilter);**
throw( CDaoException, CMemoryException );

Return Value

Nonzero if matching records are found, otherwise 0.

Parameters

lFindType

A value indicating the type of Find operation desired. The possible values are:

  • AFX_DAO_NEXT   Find the next location of a matching string.

  • AFX_DAO_PREV   Find the previous location of a matching string.

  • AFX_DAO_FIRST   Find the first location of a matching string.

  • AFX_DAO_LAST   Find the last location of a matching string.

lpszFilter

A string expression (like the WHERE clause in an SQL statement without the word WHERE) used to locate the record. For example:

Find(AFX_DAO_FIRST, "colRecID = 7")
Find(AFX_DAO_NEXT, "customerName = 'Jones'")

Remarks

Call this member function to locate a particular string in a dynaset- or snapshot-type recordset using a comparison operator. You can find the first, next, previous, or last instance of the string. Find is a virtual function, so you can override it and add your own implementation. The FindFirst, FindLast, FindNext, and FindPrev member functions call the Find member function, so you can use Find to control the behavior of all Find operations.

To locate a record in a table-type recordset, call the Seek member function.

Tip   The smaller the set of records you have, the more effective Find will be. In general, and especally with ODBC data, it is better to create a new query that retrieves just the records you want.

For more information about finding records, see the article in Visual C++ Programmer's Guide. For related information, see the topic "FindFirst, FindLast, FindNext, FindPrevious Methods" in DAO Help.

CDaoRecordset OverviewClass MembersHierarchy Chart

See Also   CDaoRecordset::FindFirst, CDaoRecordset::FindLast, CDaoRecordset::FindNext, CDaoRecordset::FindPrev