Solved

General SQL Error question

Posted on 2002-05-23
5
154 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi cmd execution 6 60
Strange behavior when a form is closed 6 57
Not able to call Delphi XE10 dll function from Delphi 6.0 4 26
Twebbrowser add css to the header 3 25
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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