From: Campbell, Greg <greg.campbell@us.michelin.com>
To: Ludek Finstrle <luf@pzkagis.cz>
Cc: Dave Page <dpage@vale-housing.co.uk>
Cc: pgsql-odbc@postgresql.org
Subject: Re: VB6 and RowCount fix
Date: Sun, 18 Dec 2005 15:51:52 -0500
Message-ID: <43A5CBE8.2080902@us.michelin.com> (raw)
In-Reply-To: <20051218194850.GA9020@soptik.pzkagis.cz>
References: <E7F85A1B5FF8D44C8A1AF6885BC9A0E485081B@ratbert.vale-housing.co.uk>
<20051218194850.GA9020@soptik.pzkagis.cz>
I am coming late to this thread.
The issue for RowCount is not in VB, but always in ADO regardless of language, although the overwhelming
majority is in VB.
The key to rs.RowCount behaviour is the type of recordset cursor you are opening.
For example
rs.CursorLocation = adUseClient
rs.Open conn, sql, adOpenStatic
debug.print rs.RowCount
will pull all the records into a client side recordset.
while
rs.CursorLocation = adUseServer
rs.Open conn, sql, adOpenForwardOnly
debug.print rs.RowCount
will attempt to open a server side cursor,
When first opened the recordset will NOT know how many rows there are (rs.RowCount = -1).
You have to iterate through a server side or ForwardOnly cursor to get a recordcount. The count may not be
accurate until the end of the recordset.
For small recordset, clearly the client side processing is better.
For large sets, like table access to millions of records, I am not sure on what is the best approach. I
typically try to redefine the approach, in those situations. I make everything I can a detached client
side recordset.
I am unclear on what calls the ADO will make to the ODBC driver, and if DECLARE/FETCH will be triggered
based on the pgodbc setup.
The only thing that should reliable in any case is rs.EOF.
I have not seen your sample VB code, but things like this make a huge difference. Again, I am late in
having this thread grab my attention. If my remarks are off-base, please ignore then and forgive me.
Ludek Finstrle wrote:
>>>I disagree. I try your example even againist MS SQL and it still returns
>>>-1. The test suite for VB6 RowCount you sent me doesn't work at all.
>>
>>The test app works perfectly well - look at the source code; all it does
>
>
> I took a look at t source code. But I don't know VB.
>
>
>>is report the value from ADODB.Recordset.RowCount. What is not clear,
>>is whether that ever worked for any data provider. I always use the
>>"while not rs.EOF..." approach when I wrote VB code in the past.
>
>
> I think the question is how VB get RowCount value. It seems to me that
> VB counts it internaly from fetched rows.
>
> I close this chapter now if noone proof the opposite.
>
> Regards,
>
> Luf
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
Attachments:greg.campbell.vcf (text/x-vcard, 239B) download
begin:vcard
fn:Greg Campbell
n:Campbell;Greg
org:Michelin North America - US5 Lexington;ENG-ASE
email;internet:greg.campbell@us.michelin.com
title:ASE Systems Engineer
tel;work:803-951-5561/x75561
x-mozilla-html:FALSE
version:2.1
end:vcard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: greg.campbell@us.michelin.com, luf@pzkagis.cz, dpage@vale-housing.co.uk
Subject: Re: VB6 and RowCount fix
In-Reply-To: <43A5CBE8.2080902@us.michelin.com>
References: <E7F85A1B5FF8D44C8A1AF6885BC9A0E485081B@ratbert.vale-housing.co.uk> <20051218194850.GA9020@soptik.pzkagis.cz> <43A5CBE8.2080902@us.michelin.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox