Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problem with LIKE

Posted on 2006-04-13
4
Medium Priority
?
158 Views
Last Modified: 2010-04-05
I'm using delphi7 connecting to MS Access2000 database using ADO.
I try to use (LIKE) in SELECT statement it's give nothing, but if I put this statement in access query it's work properly.
The statement like this:
ADO_Name.SQL.Text :=  'SELECT * FROM TableName'+
                                     ' where TableName.FieldName like '''+'*'+TextBoxName.Text+'*'+''' order by'+
                                     ' TableName.FieldName ';

This statement is work properly without (LIKE).

0
Comment
Question by:abafadel
4 Comments
 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 2000 total points
ID: 16443784
Try:

ADO_Name.SQL.Text :=  'SELECT * FROM TableName'+
                                     ' where TableName.FieldName like '''+'%'+TextBoxName.Text+'%'+''' order by'+
                                     ' TableName.FieldName ';

Regards
Pierre
0
 
LVL 6

Expert Comment

by:saravananvg
ID: 16443791
Hello sir,

  It is not *, replace it with % and give the query as follows

ADO_Name.SQL.Text :=  'SELECT * FROM TableName'+
                                     ' where TableName.FieldName LIKE ''%' + Trim(TextBoxName.Text) + '%'' ORDER BY +
                                     ' TableName.FieldName ';
with regards,
padmaja.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 16445026
FieldName is some string type I hope, not DATE or TIME ?
0
 
LVL 5

Expert Comment

by:Voodooman
ID: 16457682
Hi

Pierre C is correct as is saravananvq.

Access uses DAO which uses '*' for the wild card ADO uses '%'.

You might wonder why Microsoft are still using DAO - its 5 times faster is why......

Voodooman
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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 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