By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,983 Members | 1,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,983 IT Pros & Developers. It's quick & easy.

Sql Connection

P: n/a
Can you have Persistent Connection (always open)
in Dot.net
I have multiple calls i have to make back to the server
would like to keep the connection open...

or is this a mute point since pooling is handling cached connections

Tks
DaveP
Oct 1 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Oct 1, 5:12 pm, "DaveP" <dvs_...@sbcglobal.netwrote:
Can you have Persistent Connection (always open)
in Dot.net
I have multiple calls i have to make back to the server
would like to keep the connection open...

or is this a mute point since pooling is handling cached connections

Tks
DaveP
By default connections are kept open as long as possible (Connection
Lifetime connection string property defaults to 0). With connection
pooling enabled (the default), Close() just releases the connection
back to the pool.

Oct 1 '07 #2

P: n/a
DaveP,

You can have a persistent connection, but to be honest, you are better
off opening the connection when you need it, and then closing it when you
are done. If you are going to do a number of database operations in a
well-defined context, then I would say it's fine to keep the connection open
for that context and close it when that context is left.

However, I think that doing this (keeping a connection open) is
considered a premature optimization.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"DaveP" <dv*****@sbcglobal.netwrote in message
news:on****************@newssvr17.news.prodigy.net ...
Can you have Persistent Connection (always open)
in Dot.net
I have multiple calls i have to make back to the server
would like to keep the connection open...

or is this a mute point since pooling is handling cached connections

Tks
DaveP


Oct 1 '07 #3

P: n/a


Open Late
Use quickly
Close Early

is the best advice 99.9% of the time.
If you need to do (2 to N operations) during the "Use Quickly" part, then
that's ok.

But if you're keeping it open for the sake of keeping it open, then that's a
bad practice.


"DaveP" <dv*****@sbcglobal.netwrote in message
news:on****************@newssvr17.news.prodigy.net ...
Can you have Persistent Connection (always open)
in Dot.net
I have multiple calls i have to make back to the server
would like to keep the connection open...

or is this a mute point since pooling is handling cached connections

Tks
DaveP


Oct 1 '07 #4

P: n/a
im in a loop...making repeted calls to the data base retrieviing ids for the
offline record set
normally i close the connections when im finished..but
here in a loop ..i think id like to keep it open til finished
looping

i can't seem to keep it open...im using DataReader
any help thanks
oh server is Sql2005

Tia
DaveP

"DaveP" <dv*****@sbcglobal.netwrote in message
news:on****************@newssvr17.news.prodigy.net ...
Can you have Persistent Connection (always open)
in Dot.net
I have multiple calls i have to make back to the server
would like to keep the connection open...

or is this a mute point since pooling is handling cached connections

Tks
DaveP


Oct 2 '07 #5

P: n/a
"Arnshea" <ar*****@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
On Oct 1, 5:12 pm, "DaveP" <dvs_...@sbcglobal.netwrote:
>Can you have Persistent Connection (always open)
in Dot.net
I have multiple calls i have to make back to the server
would like to keep the connection open...

or is this a mute point since pooling is handling cached connections

Tks
DaveP

By default connections are kept open as long as possible (Connection
Lifetime connection string property defaults to 0). With connection
pooling enabled (the default), Close() just releases the connection
back to the pool.
Actually, the "Connection Lifetime = 0" defaults to 6 minutes. That means
that the pool manager closes the physical connection after 6 minutes
inactivity.
That also means that you will incur a "physical connection" overhead if you
aren't "re-opening" the connection within this interval.

Willy.


Oct 2 '07 #6

P: n/a
DaveP wrote:
im in a loop...making repeted calls to the data base retrieviing ids for the
offline record set
normally i close the connections when im finished..but
here in a loop ..i think id like to keep it open til finished
looping
This sounds bad to me but maybe I'm just misunderstanding it. Mind
providing an example?
i can't seem to keep it open...im using DataReader
any help thanks
oh server is Sql2005
What about what it is telling you it is not persisting the connection
object?

Posting a simple example would do wonders.

Chris.
Oct 2 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.