(Mike Mitchell)
7/20/2012 9:22:00 AM
On Fri, 20 Jul 2012 01:28:06 -0500, ralph <nt_consulting64@yahoo.com>
wrote:
>On Thu, 19 Jul 2012 21:23:46 +0100, MM <kylix_is@yahoo.co.uk> wrote:
>
>>Extract from the code:
>>
>>Set Conn = New ADODB.Connection
>>OpenConnection Conn, DatabaseName
>>
>>Set rs = New ADODB.Recordset
>>rs.Open SQL, Conn, adOpenStatic, adLockOptimistic, adAsyncFetch
>>Set vsFlexHeaders.DataSource = rs ' <----- Automation Error
>>
>>The Automation Error is always "The object invoked has disconnected
>>from its clients."
>>
>>If I repeat exactly the same code (same SQL, same everything) the AE
>>doesn't occur. If I put in an error handler, then Resume back to the
>>same line, i.e. Set vsFlexHeaders.DataSource = rs then the error
>>doesn't occur.
>>
>>I haven't yet been able to pin down exactly the particular sequence
>>that leads to the AE, but it's roughly like this:
>>
>>One of the Access database fields is a Boolean. The other fields are a
>>mix of numeric, text and date. There are 6 fields in the RecordSet
>>(this is all MDAC 2.8 BTW)
>>
>>I can either select all records, approximately 80,000, or I can select
>>only those records where the Boolean is True. (The Boolean signifies a
>>special condition on the record(s) in question.)
>>
>>The sequence is:
>>
>>1. Select all records.
>>
>>2. Flag with mouse in grid the records to be downloaded.
>>
>>3. Select only records where Boolean field = True
>>
>>4. Automation Error.
>>
>>I've tried changing adOpenStatic to adOpenKeyset and I've also tried
>>without the adAsyncFetch (commented it out), but nothing I've tried so
>>far has made any difference.
>>
>>I'm going to carry on looking, but has anyone seen this error when
>>setting a grid's Datasource to a recordset?
>>
>>BTW, in break mode I've checked that the recordset leading to the AE
>>is all hunky dory, i.e. if two records were flagged for download, then
>>the recordset contains two records. It all looks fine.
>>
>>Never had this AE before.
>>
>
>Always a painful error.
>
>What's odd in your case is the fact that you get the error on first
>attempt. Usually this error occurs on subsquent attempts with the
>initial call being error free. This is because while the details will
>vary the exact cause always comes down to a vague, highly technical -
>"something has changed and is not as expected". <g>
>
>The cure is to try and remove the chances for surprises.
>
>1) Make sure for a given connection session (database, provider, mode)
>there is one and only one Connection object for the lifetime of your
>program. Create it once (New, CreatObject), then open and close as
>needed.
>
>2) Try and clear out the vsFlexGrid before assigning a new source.
> If using VirtualData, set it to false
> Set vsFlexHeaders.DataSource to Nothing
> Then assign the new datasource
>
>[While it likely has nothing to do with this problem, note that just
>saying you are using MDAC 2.8, tells us nothing about which version of
>ADO you are using - ie, ADO 2.5, ADO 2.8, ... (Except of course you
>can't be using ADO 2.1. <g>) I usually use ADO 2.8 with vsFlexGrid 8.]
I'm doing some proof-reading right now, but I'll get back to the app
later this morning. However, I've just read your post and am confused
about ADO and MDAC. I thought the two terms were synonymous! That is,
if one is using MDAC 2.8, then one is using the latest ADO. I don't
recall ever updating ADO specifically. When I check my References list
in VB6 I have "Microsoft ActiveX Data Objects 2.8 Library" listed and
that is the one I choose nowadays. (I still have references to the
older 2.7, 2.6, 2.5, 2.1 and 2.0 versions.)
MM