Solved

General SQL Error question

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

Accepted Solution

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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