?
Solved

General SQL Error question

Posted on 2002-05-23
5
Medium Priority
?
160 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 7 hours left to enroll

752 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