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!