Home All Groups Group Topic Archive Search About

ChangeDatabase and connection pooling

Author
6 Jan 2006 7:45 PM
Nate
Hello All,

I have a web application that uses multiple databases all residing on the
same SQL Server with similar info, thus 1 aspx page will reference one of 10
possible databases depending on what the user is doing.  Now, I want all my
connections to the database server to reside in the same connection pool.

So, I was thinking about using a single connection string to connect to
'master' for every page, then invoke
SqlConnection.ChangeDatabase("other_database").  The question then is... by
calling ChangeDatabase to point to a different database, will that remove
that connection from the connection pool?  If so, can I return it to the pool
by calling ChangeDatabase() again before disconnecting to point back to
'master'?

Thanks in advance for your help,

Author
7 Jan 2006 2:32 AM
William (Bill) Vaughn
The connection pooling mechanism can be monitored to see what it does.
Generally, it inspects the ConnectionString. If it's the same, the mechanism
assumes you're working with the same
server/database/user/transaction/process context.


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Show quote
"Nate" <N***@discussions.microsoft.com> wrote in message
news:3DB572DC-6636-42A3-B2FE-70A4966FD080@microsoft.com...
> Hello All,
>
> I have a web application that uses multiple databases all residing on the
> same SQL Server with similar info, thus 1 aspx page will reference one of
> 10
> possible databases depending on what the user is doing.  Now, I want all
> my
> connections to the database server to reside in the same connection pool.
>
> So, I was thinking about using a single connection string to connect to
> 'master' for every page, then invoke
> SqlConnection.ChangeDatabase("other_database").  The question then is...
> by
> calling ChangeDatabase to point to a different database, will that remove
> that connection from the connection pool?  If so, can I return it to the
> pool
> by calling ChangeDatabase() again before disconnecting to point back to
> 'master'?
>
> Thanks in advance for your help,
Author
7 Jan 2006 3:16 PM
Nate
Bill,

What technique can I use, either in code or in some separate application, to
monitor the pooling mechanism?

Thanks,
Nate

Show quote
"William (Bill) Vaughn" wrote:

> The connection pooling mechanism can be monitored to see what it does.
> Generally, it inspects the ConnectionString. If it's the same, the mechanism
> assumes you're working with the same
> server/database/user/transaction/process context.
>
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> INETA Speaker
> www.betav.com/blog/billva
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no rights.
> __________________________________
>
> "Nate" <N***@discussions.microsoft.com> wrote in message
> news:3DB572DC-6636-42A3-B2FE-70A4966FD080@microsoft.com...
> > Hello All,
> >
> > I have a web application that uses multiple databases all residing on the
> > same SQL Server with similar info, thus 1 aspx page will reference one of
> > 10
> > possible databases depending on what the user is doing.  Now, I want all
> > my
> > connections to the database server to reside in the same connection pool.
> >
> > So, I was thinking about using a single connection string to connect to
> > 'master' for every page, then invoke
> > SqlConnection.ChangeDatabase("other_database").  The question then is...
> > by
> > calling ChangeDatabase to point to a different database, will that remove
> > that connection from the connection pool?  If so, can I return it to the
> > pool
> > by calling ChangeDatabase() again before disconnecting to point back to
> > 'master'?
> >
> > Thanks in advance for your help,
>
>
>
Author
7 Jan 2006 5:09 PM
William (Bill) Vaughn
The Framework exposes performance counters that can monitor the pool, but
only the 2.0 version counters are particularly reliable.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Show quote
"Nate" <N***@discussions.microsoft.com> wrote in message
news:A522F71F-3BC5-4DCC-90D9-D879CE024620@microsoft.com...
> Bill,
>
> What technique can I use, either in code or in some separate application,
> to
> monitor the pooling mechanism?
>
> Thanks,
> Nate
>
> "William (Bill) Vaughn" wrote:
>
>> The connection pooling mechanism can be monitored to see what it does.
>> Generally, it inspects the ConnectionString. If it's the same, the
>> mechanism
>> assumes you're working with the same
>> server/database/user/transaction/process context.
>>
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant
>> Microsoft MVP
>> INETA Speaker
>> www.betav.com/blog/billva
>> www.betav.com
>> Please reply only to the newsgroup so that others can benefit.
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>> __________________________________
>>
>> "Nate" <N***@discussions.microsoft.com> wrote in message
>> news:3DB572DC-6636-42A3-B2FE-70A4966FD080@microsoft.com...
>> > Hello All,
>> >
>> > I have a web application that uses multiple databases all residing on
>> > the
>> > same SQL Server with similar info, thus 1 aspx page will reference one
>> > of
>> > 10
>> > possible databases depending on what the user is doing.  Now, I want
>> > all
>> > my
>> > connections to the database server to reside in the same connection
>> > pool.
>> >
>> > So, I was thinking about using a single connection string to connect to
>> > 'master' for every page, then invoke
>> > SqlConnection.ChangeDatabase("other_database").  The question then
>> > is...
>> > by
>> > calling ChangeDatabase to point to a different database, will that
>> > remove
>> > that connection from the connection pool?  If so, can I return it to
>> > the
>> > pool
>> > by calling ChangeDatabase() again before disconnecting to point back to
>> > 'master'?
>> >
>> > Thanks in advance for your help,
>>
>>
>>

AddThis Social Bookmark Button