Re: CurrentDb in ADP
- From: "Brendan Reynolds" <brenreyn@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 13 Oct 2005 22:23:05 +0100
Thanks Robert.
--
Brendan Reynolds
"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:e3gyJkD0FHA.3812@xxxxxxxxxxxxxxxxxxxxxxx
> It applies pretty much anywhere that you use any connection in ADO (though
> I think they changed how it works in ADO.NET).
>
>
>
> Rob
>
> "Brendan Reynolds" <brenreyn@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:uQAxdYC0FHA.3588@xxxxxxxxxxxxxxxxxxxxxxx
>> Thanks Robert,
>>
>> Do you happen to know, is this a general ADO issue or is it specific to
>> ADPs, e.g. does the same apply when using CurrentProject.Connection in an
>> MDB?
>>
>> --
>> Brendan Reynolds
>>
>> "Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:OM59JQC0FHA.3588@xxxxxxxxxxxxxxxxxxxxxxx
>>> Just a quick note: Brendan has fallen victim to one of the most common
>>> typos and/or little-known facts of ADO in terms of opening a recordset.
>>>
>>>> In an ADP using ADO ...
>>>>
>>>> rst.ActiveConnection = CurrentProject.Connection
>>>> rst.Source = "SELECT * FROM SomeTable"
>>>> rst.Open
>>>
>>> If you do it this way, ADO will open a separate connection object with
>>> the same properties as the current connection. In essence, it logs into
>>> SQL Server twice (or 10 times if you have 10 different recordsets, etc.)
>>>
>>> In order to use the same connection, you need to use the "Set" command
>>> when assigning the connection:
>>>
>>> Set rst.ActiveConnection = CurrentProject.Connection
>>> rst.Source = "SELECT * FROM SomeTable"
>>> rst.Open
>>>
>>> If I remember correctly, this isn't necessary if you're doing the
>>> one-liner style of opening a recordset, as the connection will properly
>>> be evaluated as a reference...but you might want to double-check on
>>> that.
>>>
>>> rst.Open "SELECT * FROM SomeTable", CurrentProject.Connection [, ...]
>>>
>>>
>>>
>>> Rob
>>>
>>
>>
>
>
.
- References:
- Re: CurrentDb in ADP
- From: Brendan Reynolds
- Re: CurrentDb in ADP
- From: Robert Morley
- Re: CurrentDb in ADP
- From: Brendan Reynolds
- Re: CurrentDb in ADP
- From: Robert Morley
- Re: CurrentDb in ADP
- Prev by Date: Re: CurrentDb in ADP
- Next by Date: Re: MDB vs ADP
- Previous by thread: Re: CurrentDb in ADP
- Next by thread: Re: CurrentDb in ADP
- Index(es):
Relevant Pages
|