?
Solved

General SQL Error question

Posted on 2002-05-23
5
Medium Priority
?
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 46

Accepted Solution

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

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

650 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