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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Like in ADO query

Status
Not open for further replies.

rewdee

Programmer
Aug 17, 2001
295
US
I am using ADOQuery component on a MS Access Database. The SQL is built on a search form. The Search form works correctly except when I use wildcards. I have displayed the SQL.Text on the web page and it looks like this:
Code:
============
SELECT * FROM Table1 WHERE Field1 Like 'ab*'
============
If I copy and paste into MS Access 2000, the query returns x number of records but in my ISAPI Dll none are returned.

The code to generate the SQL is
Code:
============
with qry do
begin
  ...
   SQL.Add('WHERE FrameNum Like ' + QuotedStr(sParam));
   ...
end;
============
Anyone see anything I'm doing wrong here?

Thanks,
Rewdee
 
I suspect that Ado understands the % wildcard.

I use:
SQL.Add('WHERE FrameNum Like :QuotedString');
ParamByName('QuotedString').AsString := MyString;

In your example MyString := 'ab%' for the matches beginning with ab or '%ab%' for the matches containing ab

Regards S. van Els
SAvanEls@cq-link.sr
 
I think I do want to use the * wildcard (all records that begin with say ab). I believe you also misunderstand what my problem is. To generate the valid Access SQL statement
Code:
SELECT * FROM tbl1 WHERE Field1 Like 'ab*'

I use Delphi's QuotedStr function (to wrap my string in quotes). If I did not use the QuotedStr function it would be something like:
Code:
with qry do
begin
  ...
   SQL.Add('WHERE FrameNum Like ''''sParam'''');
   ...
end;
where sParam could equal something like ab*

Any other suggestions or hints I surely would appreciate it.

Thanks,
Rewdee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top