Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering with ADOQuery

Status
Not open for further replies.

Punchinello

Programmer
Apr 25, 2003
116
US
I'm using TADOQuery against an Access database (converted to SQL Server in production) and want to provide user-controlled filtering displayed in a standard DBGrid.

The SQL statement is a simple SELECT and I want to apply a filter on the field in the ORDER BY clause so I set the Filter like LastName = 'Smith*' wanting the "*" to indicate a partial match, and turn Filtered to True.

But wait! The ADOQuery says that the FilterOptions is not supported! So how can I use the filter properties for partial matches?
 
As it turns out, it works exactly as intended when the filter (using the prior example) uses the LIKE operator instead of the = operator with wildcards.

So:
LastName = 'SMI*' does not work, but
LastName LIKE 'SMI*' does work.

When using ADO components, the filter option appears to mirror the SQL Syntax.
 
hi,

use lastname like 'SMI%'

--------------------------------------
What You See Is What You Get
 
Right you are whosrdaddy.

Actually both the '*' and the '%' work the same, but since the '%' reflects standard SQL syntax, that's what I'm using. Thanks for the reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top