473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Sql Connection

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
6 2261
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
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


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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: G-Fit | last post by:
Hello group, I have several servers hosting SQL databases. On each of them, I have several databases. All those databases have the same structure (even those on different servers), only the data...
11
by: pradeep_TP | last post by:
Hi all, I have a few questions that I have been wanting to ask for long. These are all related to ADO.net and specifically to conenction to database. 1) If I have opened a connection to a...
35
by: Eric Sabine | last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET connection object, SQLConnection to be exact) and then I came across the following in some microsoft code. If Not cn Is Nothing...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
35
by: Terry Jolly | last post by:
Web Solution Goal: Have a global database connection Why: (There will be 30+ tables, represented by 30+ classes) I only want to reference the database connection once. I put the connection...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
3
by: fniles | last post by:
In the Windows application (using VB.NET 2005) I use connection pooling like the following: In the main form load I open a connection using a connection string that I stored in a global variable...
6
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
0
by: Robert Avery | last post by:
In VBA/VB6, I had a class (incomplete sample below) that watched and displayed for the user all connection events, so that I could easily see what SQL was taking a long time, and when it freezes, I...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.