Search code examples
delphims-accessdelphi-7ms-access-2003

ADOQuery.Filter not working with LIKE


I have a query in ADOQuery2. Now I want have a filter for that so:

  ADOQuery2.Filter := 'where Fname like ' + QuotedStr(Txt_Search.Text + '*');
  ADOQuery2.Filtered := true;

but it throws this exception: (* in like statement is for Access instead of %)

enter image description here

any idea?


Solution

  • When using the LIKE operator from within Access itself the asterisk * is the correct wildcard character, but for ADO connections from other applications (like yours) you should actually be using the "standard" percent % wildcard character for SQL.