CRecordset::m_strFilter
Remarks
After you construct the recordset object, but before you call its Open member function, use this data member to store a CString containing an SQL WHERE clause. The recordset uses this string to constrain — or filter — the records it selects during the Open or Requery call. This is useful for selecting a subset of records, such as “all salespersons based in California” (“state = CA”). The ODBC SQL syntax for a WHERE clause is
WHERE search-condition
Note that you do not include the WHERE keyword in your string. The framework supplies it.
You can also parameterize your filter string by placing ‘?’ placeholders in it, declaring a parameter data member in your class for each placeholder, and passing parameters to the recordset at run time. This lets you construct the filter at run time. For more information, see the article in Visual C++ Programmer’s Guide.
For more information about SQL WHERE clauses, see the article . For more information about selecting and filtering records, see the article . Both articles are in Visual C++ Programmer’s Guide.
Example
// Example for CRecordset::m_strFilter
CCustSet rsCustSet( NULL );
// Set the filter
rsCustSet.m_strFilter = “state = 'CA'”;
// Run the filtered query
rsCustSet.Open( CRecordset::snapshot, "Customers" );
CRecordset Overview | Class Members | Hierarchy Chart
See Also CRecordset::m_strSort, CRecordset::Requery