Solved

Help Needed with TQuery SQL Error

Posted on 2007-11-16
3
185 Views
Last Modified: 2010-04-21
Hi all,

I am having a problem with an SQL Query.

This is the code:

 ADOQuery1.SQL.Add('select * from TheTable where (Make) = "' + (Edit1.Text) + '"');

Now...this wrks fine IF results are found but I get an error if there are no matches found.

How could I modify this so that IF there are no matches found I can do a Showmessage('No Matches Found') or something link this.

Hope you can help!

Thanks

ST3VO
0
Comment
Question by:ST3VO
3 Comments
 
LVL 13

Expert Comment

by:rfwoolf
ID: 20297269
Could you perhaps do a record count on the dataset?
i.e.
if ADOQuery1.RecordCount > 0 then do
  begin
etc
0
 
LVL 6

Accepted Solution

by:
bokist earned 500 total points
ID: 20297270
Try this way:

ADOQuery1.SQL.Add('select * from TheTable where (Make) = "' + (Edit1.Text) + '"');
ADOQuery1.Open;
if ADOQuery1.EOF  then  
  begin
  Showmessage('No Matches Found') ;
  Exit;
end;
0
 

Author Closing Comment

by:ST3VO
ID: 31409525
Excellent!!! Worked Great! Thanks!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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