Solved

Help Needed with TQuery SQL Error

Posted on 2007-11-16
3
188 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

838 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