Re: Operator in SQL like "Like"

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Kettrickenfef (Kettrickenfef_at_discussions.microsoft.com)
Date: 02/11/05


Date: Fri, 11 Feb 2005 03:37:04 -0800

I tried changing the wildcard characters and it didn't recognise them so I
had to change them back.

I have an Access database with a table called "product". I want to create a
query that uses this. The SQL that Access gives me for the query I am trying
to create is this:

SELECT [Product Table].ProdID, [Product Table].Supplier, [Product
Table].Descr, [Product Table].CustomerPrice
FROM [Product Table]
WHERE ((([Product Table].Descr) Like "*clock*"))
ORDER BY [Product Table].ProdID;

But I want to use this through Delphi. To do this, I have to use an ADO
query. I don't know if this is possible as the Access help says this:
"The Microsoft Jet database engine uses the Microsoft® Visual Basic® for
Applications (or VBA) expression service to perform simple arithmetic and
function evaluation. All of the operators used in Microsoft Jet SQL
expressions (except Between , In , and Like ) are defined by the VBA
expression service."
So it may be that the Like operator for Access SQL cannot be used in Delphi.

But the code I am trying to write to do this is this:

begin
          ADOQryDescr.close;
          ADOQryDescr.Parameters[1].Value := edtDescr.Text;
          with ADOQryDescr.SQL do
            begin
              clear;
              add('SELECT [Product Table].ProdID, [Product Table].Supplier,
[Product Table].Descr, [Product Table].CustomerPrice FROM [Product Table]');
              add('WHERE (([Product Table].Descr Like "* (:descr)*")');
              add('ORDER BY [Product Table].ProdID;');
            end;
          ADOQryDescr.Active:=true;
          ADOQryDescr.Open;
        end;

(I am passing the text using a parameter, descr, which is defined correctly)
And it doesn't work, so I don't know if it's a problem with my code, or with
Delphi not being able to use the Like operator, or what, and whether or not
there is another operator I can use instead? Thank you!



Relevant Pages

  • ANSI defaults, Linked Server
    ... Access database that our Credit Card processing software uses. ... written a SP to grab some data from this Linked Server, and from my local SQL ... Enable these options and the reissue your query" ...
    (microsoft.public.sqlserver.programming)
  • Re: Running a Query
    ... in your "code" (it's called a SQL statement, ... query in design view. ... the SQL is presented in the query grid. ... >> is the Members table in the Access database where you're building the ...
    (microsoft.public.access.queries)
  • Pass-Through, Default DSN?
    ... I am converting my companies Access database to SQL ... as a front end to connect to SQL Server. ... Through query so it connects to the ODBC to run the query, ...
    (microsoft.public.access.queries)
  • RE: How to simple retrieve autonumber valuees or identity from data so
    ... you can write the equivalent of a stored procedure in Access. ... Simply write your SQL in a query and save it. ... > I use the access database in my simple application. ...
    (microsoft.public.dotnet.framework.adonet)
  • WHERE constants for DateTime
    ... I am working with an Access Database (using SQL from Delphi). ... Piedro Mazolo ...
    (borland.public.delphi.database.ado)