Re: Question about Connection Pooling in ASP

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Bob Barrows [MVP] (reb01501_at_NOyahoo.SPAMcom)
Date: 01/23/05


Date: Sat, 22 Jan 2005 20:32:07 -0500

Dr. Know wrote:
> Bob,
>
> Thanks! And as always - great info.
> I search MSDN for answers before asking here, but many time I come up
> with 100's of hits, even with fairly specific queries. You must keep
> a database of "favorite best references" in your quick launch bar...
>
>> Basically, as long as you close connections as soon as you are
>> finished with them, releasing them to the session pool, you will be
>> taking full advantage of pooling. If you do things to prolong
>> connections, such as recordset loops using connected recordsets,
>> instead of utilizing GetString, GetRows
>> (http://www.aspfaq.com/show.asp?id=2467) or disconnected recordsets,
>> you
>> will not get the full benefit from pooling, even though it is still
>> turned on.
>
> I am assuming that an open such as:
>
> objRst.Open "SELECT TOP 1 [highnumber] FROM [dbffile] _
> ORDER BY [highnumber] DESC", _
> objConn, adOpenStatic, adLockreadOnly, adCmdText
>
> var = CLng(objRst("highnumber"))
>
> objRst.Close
> set objRst = Nothing
>
> would see no performance penalty, and may possibly be superior due
> to the lack of string handling, over using GetRows or GetString -
> since you are only retrieving one value and closing the recordset?

Even better would be to use the default forwardonly cursor instead of the
static cursor, but frankly, I doubt you would see the difference.

>
> Reading your other references leaves me with the impression that
> different access modes should be declared specifically as different
> connections - or does the connection pool manager handle this
> transparently in the background?

Different access modes will force new connections. But i do not think we are
talking about the same thing ...

>
> And although this doesn't apply to my current scenario, this implies
> that two recordsets which are open at the same time should also be
> declared as different PROVIDER connections - rather than trying to
> share one connection definition.
>
> In other words, should a connection to a recordset with a readonly,
> forward cursor to a specific database should be declared as
> PROVIDER_1, and a dynamic recordset with optimistic locking be
> declared as PROVIDER_2 - rather than a single non-specific declaration
> that relies on the recordset open options to determine the cursor
> mode. Or does it not matter.
>

No, it does not matter. There is no point to opening two connections. The
cursor type and location, and locktype are properties of the recordset, not
the connection. The properties that are set at the connection level simply
control the default settings of the same properties of the individual
recordsets.

>
> Const PROVIDER = "Provider=vfpoledb;Data Source=C:\DBFILESLOC\;
>
> VS:
>
> Const PROVIDER_1 = "Provider=vfpoledb; _
> Data Source=C:\DBFILESLOC\; _
> Mode=ReadOnly | Share DenyNone;"
>
> Const PROVIDER_2 = "Provider=vfpoledb; _
> Data Source=C:\DBFILESLOC\; _
> Mode=ReadWrite | Share DenyWrite;"

This (Mode) is the setting that requires separate connections, but i would
never do this. if i am opening several recordsets, I will use a single
connection.

>
>
> And the last question...
> Will I *ever* learn enough to be a truly masterful programmer? :-|
>

Maybe. I'm not a masterful one yet ... (believe me, i am not being modest)

Bob Barrows

-- 
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM" 


Relevant Pages

  • Re: multiple connection view
    ... His other post he was asking about creating a recordset from two already ... > servers and rowset functions. ... > different heterogeneous data sources (for instance, joining data in a SQL ... >>>>> b but tables a and b are from two different connections. ...
    (microsoft.public.vb.database.ado)
  • Re: Question about Connection Pooling in ASP
    ... If you do things to prolong connections, such as recordset loops ... declared as PROVIDER_2 - rather than a single non-specific declaration ... that relies on the recordset open options to determine the cursor ...
    (microsoft.public.inetserver.asp.db)
  • Re: Is this server, client or jet engine problem?
    ... recordset they do a loop looking for matching records in the database. ... > Thanks for the response all the connections are closed on each page. ... >> Try switching to the native Jet OLEDB provider rather than the obsolete ... >> quicker response by posting to the newsgroup. ...
    (microsoft.public.inetserver.asp.db)
  • Re: Connections query
    ... If we modified code like this ... we close recordset before another object is ... And you will find that no more connections are made, which is to say, ... Online Partner Support Specialist ...
    (microsoft.public.sqlserver.programming)
  • Re: The easiest framework for Java Database applications development released for production use
    ... This results in a cursor being left open in the ... that opens a cursor in the database fails. ... But if you don't close the connections then they ...
    (comp.lang.java.programmer)