Board index » delphi » Avoid Recordcount method?

Avoid Recordcount method?

I often need to check the existance of records before doing an action.
To do this I just insert a quick...

if query1.recordcount > 0 then
  begin

  end;

The D4 help file suggests to avoid using the RecordCount method.
What would be a good alternative?

 

Re:Avoid Recordcount method?


I usually just check to see if the dataset is EOF.  In other words

if not query1.eof do
begin
end;

if there are no records in the dataset, then eof is true as soon as it
opens.

Ryan McGinty
OCERIS, Inc.
http://www.oceris.com

Quote
Emmanuel Samios wrote in message <01be0736$640489c0$25b93ecb@osborne>...
>I often need to check the existance of records before doing an action.
>To do this I just insert a quick...

>if query1.recordcount > 0 then
>  begin

>  end;

>The D4 help file suggests to avoid using the RecordCount method.
>What would be a good alternative?

Re:Avoid Recordcount method?


We have always had this problem, particularly with SQL Server.  As a
workaround we issue a

query1.last;
query1.first;

then check query1.recordcount

or we check for existence of data by issueing

if not query1.IsEmpty then

On 3 Nov 1998 15:28:02 GMT, "Emmanuel Samios"

Quote
<emman...@adaptabase.com.au> wrote:
>I often need to check the existance of records before doing an action.
>To do this I just insert a quick...

>if query1.recordcount > 0 then
>  begin

>  end;

>The D4 help file suggests to avoid using the RecordCount method.
>What would be a good alternative?

Re:Avoid Recordcount method?


Quote
>The D4 help file suggests to avoid using the RecordCount method.
>What would be a good alternative?

Try the "IsEmpty" method. It's very fast.

Re:Avoid Recordcount method?


On 3 Nov 1998 15:28:02 GMT, Emmanuel Samios wrote:

Quote
>I often need to check the existance of records before doing an action.

Use the IsEmpty method.

sig://boB/TeamB

Other Threads