Solved

Query.recordcount always gives 1 record ?

Posted on 2004-08-13
2
143 Views
Last Modified: 2010-04-05
Hi

Can anyone help me with this problem.

I hava a Paradox table. When I use a Query, and I know for certain, that the result will be an empty query, the recordcount of that query gives me 1 record instead of 0 . When there is one record that matches the query, the recordcount is also one !!!

quid ?

thx a lot
0
Comment
Question by:marioway
2 Comments
 
LVL 12

Accepted Solution

by:
esoftbg earned 50 total points
ID: 11797700
Try to use another query when you need to know the count of records:

function  TForm1.CountOfRecords(TableName: string): Integer;
var
  Count: Integer;
begin
  Count := 0;
  try
    QueryCount.Active := False;
    QueryCount.SQL.Text :=''
                        + 'SELECT COUNT(*) FROM '
                        + TableName
                        + '';
    QueryCount.Active := True;
    Count := QueryCount.Fields[0].AsInteger;
  finally
    Result := Count;
  end;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  EditCount.Text := IntToStr(CountOfRecords('EMPLOEE'));
end;
0
 

Author Comment

by:marioway
ID: 11799847
Thank You very much esoftbg

Marioway
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

9 Experts available now in Live!

Get 1:1 Help Now