Solved

Help Needed with TQuery SQL Error

Posted on 2007-11-16
3
182 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
Comment Utility
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
Comment Utility
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
Comment Utility
Excellent!!! Worked Great! Thanks!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now