Happy Day.

EOF should not be true while you are on the first record of a recordset. 
 EOF shouldn't be true until you traverse past the last record.
Do you have the following layout?

qry.Open;
while not qry.EOF do
begin
  { do something here }
  qry.Next;
end;
qry.Close;

Be careful that the EOF you're using is indeed the EOF property of the 
TQuery in question.  That is, watch your "withs".

As for getting the number of records in a recordset, the RecordCount 
property of TQuery sounds like a wonderful thing, but we've actually 
encountered some problems with it.  We have been able to faithfully 
recreate circumstances under Oracle where the RecordCount property returns 
-1!  We've seen it occasionally under Interbase.  It's also rather slow as 
it traverses all the records of the query and comes back - you're better 
off using SELECT COUNT(*) in a separate query and letting the server handle 
the work.

However....

Most often you don't need the count of records, you just want to know:
(a) Are there ANY Records?
(b) Am I at the LAST record yet?

The answer to these questions:
(a) If EOF and BOF (if you're at the beginning AND the end, there aren't 
any records).
(b) if EOF

Cheers.
                        BJ...

----------
From:   Maurice Butler[SMTP:[EMAIL PROTECTED]]
Reply To:       [EMAIL PROTECTED]
Sent:   Monday, 14 December, 1998 09:52
To:     Multiple recipients of list delphi
Subject:        [DUG]:  Tquery

<<File: ATT00000.html>>
Hi,

Is there any easy way to know how many records a select query has returned.

The problem I have is I was doing a while on EOF but if only one record is 
returned the EOF is true and my while code does not execute.

Thanks
------------------------------------------------------------------------  
--------
Maurice Butler     Like Magic Ltd    (025) 273 9248



---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to