Solved

Query.recordcount always gives 1 record ?

Posted on 2004-08-13
2
146 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 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