Solved

General SQL Error question

Posted on 2002-05-23
5
152 Views
Last Modified: 2010-04-04
Hi experts,

I got this error:
General SQL Error [Microsoft][ODBC Microsoft Access 97 Driver] Expression cannot be used with the LIKE
predicate.

when I try to retrieve some data using TQuery from a table in MSAccess 97 database.
I'm using Delphi 3, BDE version 4.0, Access97.

source:

procedure myForm.Button1Click (Sender: TObject)
var
    findTitle : string;
begin
    Edit1.Text := findTitle;
    with Query1 do
    begin
        Close;
        SQL.Clear;
        SQL.Add('SELECT * FROM Book');
        SQL.Add('WHERE Title LIKE "%' + findTitle + '%"');
        Open;
    end;
end;

If you know this error, please give me the solutions. TQ

iqmedia
0
Comment
Question by:iqmedia
5 Comments
 
LVL 3

Expert Comment

by:smurff
ID: 7029316
Just as a point. What is the value of findTitle ?
Because you are saying :

Edit1.Text := findTitle;

That would be blank... did you mean findTitle := Edit1.text ?

Regards
Smurff
0
 

Author Comment

by:iqmedia
ID: 7029318
opss.... findTitle := Edit1.Text;

TQ

iqmedia
0
 
LVL 1

Expert Comment

by:JDN
ID: 7029697
Try to use single quotes instead of double quoted:

SQL.Add('WHERE Title LIKE '+#39+'%'+findTitle+'%'+#39);

or

SQL.Add('WHERE Title LIKE '+QuotedStr('%'+findTitle+'%'));


JDN
       
0
 

Author Comment

by:iqmedia
ID: 7032165
Hi experts,

General SQL Error [Microsoft][ODBC Microsoft Access 97 Driver] Expression cannot be used with the LIKE predicate.

Whether I use double quote (") or single quote or above suggestion, the error still occur. I hope you understand the first question...

iqmedia
0
 
LVL 45

Accepted Solution

by:
aikimark earned 150 total points
ID: 7034062
The Jet engine (Access) wildcard character is an asterisk.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now