🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.database
Article #2045

Re: ADO

#2045
From: Marco Rocci
Date: Wed, 16 Dec 1998 00:00
49 lines
2578 bytes
Hi,

On Mon, 7 Dec 1998 23:07:03 +0100, "Stefan Gevaert"
<stefan.gevaert@ping.be> wrote:

>I am experimenting with ADO and Delphi. Everything works fine, except the
>RecordCount Property of the Recordset always returns -1.

(I don't know what ADO is, but...)

RecordCount=-1 means BDE does not know yet how many records there will
be.  BDE does not support RecordCount for most SQL engines unless you
do a fetch all.  This is logical as one of the reasons to use engines
is to reduce network traffic.  To know how many records there are,
these MUST be fetched from the engine.  Since fetching the entire
result set just to know how many records there are is not very
efficient (read: it is potentially TIME CONSUMING) then BDE will not
do it just because you access the RecordCount property.

If you really need to know the number of records, then I suggest:

 * if the result set is small (10 records) and you intend to read
through it programmatically anyway, then:
      Last;
      First;
   This will fetch the records, and you should be able to have a
proper RecordCount value.  The fetched data should then be cached and
a following While Not Eof loop should not create any more network
traffic.

 * if you have no idea of how big the result set will be, if you are
certain it will be big or if you are not sure you will read through it
anyway then:
   use a second TQuery similar to:
      SELECT COUNT(*) FROM ...<same as 1st query>...
   and have the engine calculate the number of records in the result
set.

Last but not Least, if you only need to test IF there are ANY records
(RecordCount>0 or RecordCount=0), than use the boolean IsEmpty method
instead of the RecordCount property.  This does not fetch all the
data.

Regards,

--
Marco Rocci
MicroEra srl
Turin, Italy
Technical Details
Message-ID: <367786d9.2581448@tor-nn1-ca.netcom.ca>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <74hjcm$t5t$1@news3.Belgium.EU.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: ffff5,b5e688e60f91bc45
X-Google-Attributes: gidffff5,public
X-Google-Thread: fd196,b5e688e60f91bc45
X-Google-Attributes: gidfd196,public
X-Google-Thread: f6386,b5e688e60f91bc45
X-Google-Attributes: gidf6386,public
X-Google-Thread: 115d96,b5e688e60f91bc45
X-Google-Attributes: gid115d96,public
From: mrocciNOSPAM@tin.it (Marco Rocci)
Subject: Re: ADO
Date: 1998/12/16
Message-ID: <367786d9.2581448@tor-nn1-ca.netcom.ca>
X-Deja-AN: 422851711
References: <74hjcm$t5t$1@news3.Belgium.EU.net>
Organization: MicroEra srl
Newsgroups: borland.public.delphi.database,borland.public.delphi.database.multi-tier,borland.public.delphi.oleautomation,comp.lang.pascal.delphi.databases