Connecting Tech Pros Worldwide Forums | Help | Site Map

Disconnected ADO recordsets lose their data

Steve Jorgensen
Guest
 
Posts: n/a
#1: Nov 13 '05
I keep having problems in which ADO disconnected recordset work under some
circumstances, but lose all their data at other times, having no rows or
fields, though the recordset object still exists.

One case where this happened to me today was in trying to store disconnected
recordsets in a cache collection in case they are needed again later in the
same session. When I retrieve the recordset from the collection, it's empty.
On the other hand, the same disconnected recordset worked fine being passed
around and used right after it was created, and prior to pulling it out of the
cache later.

I've been able to work around this problem by saving the recordsets to stream
objects (in memory, not bound to files), and storing the streams in the cache
instead of the recordsets themselves, but I don't know why streams survive
caching, and raw disconnected recordsets do not.

Dimitri Furman
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Disconnected ADO recordsets lose their data


On Jun 02 2004, 12:56 am, Steve Jorgensen <nospam@nospam.nospam> wrote
in news:l6nqb0p1odgpmrct617781fqoq6tgejdps@4ax.com:
[color=blue]
> I keep having problems in which ADO disconnected recordset work under
> some circumstances, but lose all their data at other times, having no
> rows or fields, though the recordset object still exists.
>
> One case where this happened to me today was in trying to store
> disconnected recordsets in a cache collection in case they are needed
> again later in the same session. When I retrieve the recordset from
> the collection, it's empty. On the other hand, the same disconnected
> recordset worked fine being passed around and used right after it was
> created, and prior to pulling it out of the cache later.
>
> I've been able to work around this problem by saving the recordsets to
> stream objects (in memory, not bound to files), and storing the
> streams in the cache instead of the recordsets themselves, but I don't
> know why streams survive caching, and raw disconnected recordsets do
> not.[/color]

I haven't seen this, but please post back if you find more about it. Which
version of ADO is this? Does it happen only to recordsets that you store in
cache?

--
remove a 9 to reply by email
David W. Fenton
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Disconnected ADO recordsets lose their data


Steve Jorgensen <nospam@nospam.nospam> wrote in
news:l6nqb0p1odgpmrct617781fqoq6tgejdps@4ax.com:
[color=blue]
> I keep having problems in which ADO disconnected recordset work
> under some circumstances, but lose all their data at other times,
> having no rows or fields, though the recordset object still
> exists.[/color]

Are you absolutely certain the recordset is not getting wiped? I've
had issues where recordset that are supposed to be initialized ended
up not initialized, and it ended up being because code elsewhere had
de-initialized the database variable that was the parent of the
recordset. It was a mistake in my code, obviously, but it's pretty
easy to do by accident.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Steve Jorgensen
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Disconnected ADO recordsets lose their data


On Wed, 02 Jun 2004 12:11:27 -0000, Dimitri Furman <dfurman@cloud99.net>
wrote:
[color=blue]
>On Jun 02 2004, 12:56 am, Steve Jorgensen <nospam@nospam.nospam> wrote
>in news:l6nqb0p1odgpmrct617781fqoq6tgejdps@4ax.com:
>[color=green]
>> I keep having problems in which ADO disconnected recordset work under
>> some circumstances, but lose all their data at other times, having no
>> rows or fields, though the recordset object still exists.
>>
>> One case where this happened to me today was in trying to store
>> disconnected recordsets in a cache collection in case they are needed
>> again later in the same session. When I retrieve the recordset from
>> the collection, it's empty. On the other hand, the same disconnected
>> recordset worked fine being passed around and used right after it was
>> created, and prior to pulling it out of the cache later.
>>
>> I've been able to work around this problem by saving the recordsets to
>> stream objects (in memory, not bound to files), and storing the
>> streams in the cache instead of the recordsets themselves, but I don't
>> know why streams survive caching, and raw disconnected recordsets do
>> not.[/color]
>
>I haven't seen this, but please post back if you find more about it. Which
>version of ADO is this? Does it happen only to recordsets that you store in
>cache?[/color]

In this app, it only happens to idems I store in the cache. I've also seen it
happen in other apps when I do things like try to return a disconnected
recordset via a reference parameter. I'm not sure if that's consistent,
though.
Steve Jorgensen
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Disconnected ADO recordsets lose their data


On Wed, 02 Jun 2004 15:13:56 GMT, "David W. Fenton"
<dXXXfenton@bway.net.invalid> wrote:
[color=blue]
>Steve Jorgensen <nospam@nospam.nospam> wrote in
>news:l6nqb0p1odgpmrct617781fqoq6tgejdps@4ax.com :
>[color=green]
>> I keep having problems in which ADO disconnected recordset work
>> under some circumstances, but lose all their data at other times,
>> having no rows or fields, though the recordset object still
>> exists.[/color]
>
>Are you absolutely certain the recordset is not getting wiped? I've
>had issues where recordset that are supposed to be initialized ended
>up not initialized, and it ended up being because code elsewhere had
>de-initialized the database variable that was the parent of the
>recordset. It was a mistake in my code, obviously, but it's pretty
>easy to do by accident.[/color]

Since this is ADO, and the recordset is disconnected from the database, it
-should- no longer be dependent on whether the original connection has been
closed. It is true, though, that the connection may have been closed and
reopened when this symptom appears, so I could test to see if that's what is
causing the problem.
Lyle Fairfield
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Disconnected ADO recordsets lose their data


Steve Jorgensen <nospam@nospam.nospam> wrote in
news:hnsrb0lkr38q11mu871ct9lo4vi4ltec2p@4ax.com:

[color=blue]
> In this app, it only happens to idems I store in the cache. I've also
> seen it happen in other apps when I do things like try to return a
> disconnected recordset via a reference parameter. I'm not sure if
> that's consistent, though.[/color]

Tell us about the cache, please.

--
Lyle
(for e-mail refer to http://ffdba.com/)
Steve Jorgensen
Guest
 
Posts: n/a
#7: Nov 13 '05

re: Disconnected ADO recordsets lose their data


On 2 Jun 2004 15:48:54 GMT, Lyle Fairfield <MissingAddress@Invalid.Com> wrote:
[color=blue]
>Steve Jorgensen <nospam@nospam.nospam> wrote in
>news:hnsrb0lkr38q11mu871ct9lo4vi4ltec2p@4ax.com :
>
>[color=green]
>> In this app, it only happens to idems I store in the cache. I've also
>> seen it happen in other apps when I do things like try to return a
>> disconnected recordset via a reference parameter. I'm not sure if
>> that's consistent, though.[/color]
>
>Tell us about the cache, please.[/color]

Each time the application (actually, an ActiveX DLL used by several
applications) opens a recordset, it does so by calling a function that opens
the recordset, disconnects it by setting its ActiveConnection to Nothing, then
returns it to the calling code. So far, so good because the first pass works.

The code that calls the routine described above generates a key string based
on which query is being run and what parameters are being used, and tries to
retrieve a recordset from a VBA collection acting as the cache. If a
recordset is returned, that means it was previously cached and doesn't have to
be queried again. If there was no recordset in the cache with that key, the
procedure described above is called, then the recordset is added to the cache
collection using the generated key string, so it canb e found in the cache
next time.

When I tested this, the code was breaking on the second pass for the same
query/criteria because a recordset was returned from the cache, but it was
empty and had no fields. After I changed the cache code to persist the
recordset into a stream object and cache that, then open a new recordset from
the stream when found in the cache later, the code started working properly.
Closed Thread