473,498 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I force connection pooling to keep at least one connection alive ?

Hi,

(using C#, VS2005, .NET 2.0.)

I sometimes need to access my database (SQL Server) in SINGLE_USER mode.

That works fine but after a few minutes the connection pooling seems to
automatically free the connection to the server, and doing so other computer
can connect to the database and "steal the Single User session".

Here is my question : How can I force connection pooling to keep at least
one connection open ? (that will prevent other computer to "steal" the
single user session)

Thanks for your help !

Steph.
Nov 21 '07 #1
6 4012
I haven't tested it, but you could try setting a load balance timeout
in the connection string?

http://msdn2.microsoft.com/en-us/lib...ng(VS.80).aspx

Marc
Nov 21 '07 #2
Connection pooling works based on a unique connection string, each one
defining a pool. So in this case, you would simply use a different connection
string with "pooling=off" in it.

--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"TheSteph" wrote:
Hi,

(using C#, VS2005, .NET 2.0.)

I sometimes need to access my database (SQL Server) in SINGLE_USER mode.

That works fine but after a few minutes the connection pooling seems to
automatically free the connection to the server, and doing so other computer
can connect to the database and "steal the Single User session".

Here is my question : How can I force connection pooling to keep at least
one connection open ? (that will prevent other computer to "steal" the
single user session)

Thanks for your help !

Steph.
Nov 21 '07 #3
In this scenario, that might make the problem worse; as soon as the
code closes the connection (assuming standard "open, use, close"
pattern of data-access) the /actual/ connection would be closed and
the database would be open. At least at the moment the connection is
held long enough to prevent other computers stealing access.

Of course, the better approach is to not relinqish the connection
until you are done with it, but that could require changes, especially
if the code is designed to use the "open, use, close" pattern at all
other times.

Marc
Nov 21 '07 #4
Thank-you for the helpfull link !

To use " load balance timeout" I have to give a time in minute... and it
work only with "clustered pooling" (I don't know what it is by the way...)

Instead you gave me the idea to use the "Min Pool Size=1" option; since I
use the same connection string for everything in my application I think that
this way at least one connection will remain in the pool until the
application is closed.
I tested it and it seems to work fine : In Single_User mode I do not loose
my session on the server anymore so others users cannot steal it...

Thanks !

Steph.
"Marc Gravell" <ma**********@gmail.comwrote in message
news:up**************@TK2MSFTNGP02.phx.gbl...
I haven't tested it, but you could try setting a load balance timeout
in the connection string?

http://msdn2.microsoft.com/en-us/lib...ng(VS.80).aspx
>
Marc


Nov 21 '07 #5
"TheSteph" <Th******@NoSpam.comwrote in message
news:uU**************@TK2MSFTNGP06.phx.gbl...
Thank-you for the helpfull link !

To use " load balance timeout" I have to give a time in minute... and it
work only with "clustered pooling" (I don't know what it is by the
way...)

Instead you gave me the idea to use the "Min Pool Size=1" option; since I
use the same connection string for everything in my application I think
that
this way at least one connection will remain in the pool until the
application is closed.
I tested it and it seems to work fine : In Single_User mode I do not loose
my session on the server anymore so others users cannot steal it...
Keep in mind that doing this will keep a client connected to the DB Server
for as long as the application is running, if you have many clients like
these, you'll exhaust the max. number of licensed connection with the DB
server for no good reason, more you are preventing other users to connect
even when you don't effectively need the connection.

Willy.
Nov 21 '07 #6
Yes, It was a problem...

But I solved it by doing the change in the connection string programatically
(add "Min Pool Size=1") only on the computer that enable the Single_User
mode. I then make a call to SqlConnection.ClearAllPool(), and open/close a
SqlConnection with the new connection string, and the pool will keep 1
connection only ont this computer. A check is also made at application
stratup. and a Reverse operation is made when user go back to MULTIUSER
mode.

Until now it seems to work perfectly....

Thank for your advices !

steph.
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:e3**************@TK2MSFTNGP05.phx.gbl...
"TheSteph" <Th******@NoSpam.comwrote in message
news:uU**************@TK2MSFTNGP06.phx.gbl...
Thank-you for the helpfull link !

To use " load balance timeout" I have to give a time in minute... and
it
work only with "clustered pooling" (I don't know what it is by the
way...)

Instead you gave me the idea to use the "Min Pool Size=1" option; since
I
use the same connection string for everything in my application I think
that
this way at least one connection will remain in the pool until the
application is closed.
I tested it and it seems to work fine : In Single_User mode I do not
loose
my session on the server anymore so others users cannot steal it...

Keep in mind that doing this will keep a client connected to the DB Server
for as long as the application is running, if you have many clients like
these, you'll exhaust the max. number of licensed connection with the DB
server for no good reason, more you are preventing other users to connect
even when you don't effectively need the connection.

Willy.


Nov 22 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1895
by: John | last post by:
Hi I am trying to use the internet transfer control to send some data to a site. I want my MS ISA proxy server to keep the connection alive. What syntax should I use to send the 'keep alive'...
6
7670
by: Jonas Knaus | last post by:
hello until now i allways wrote all my sql-stuff in my presentation-layer. i heard about that model of that presentation- / businesslogic- and data access layer -model. i found some example on...
18
3204
by: Rob Nicholson | last post by:
We're getting an occasional occurrence of the following error when two users try and open the same record in our ASP.NET app: "There is already an open DataReader associated with this Connection...
1
5189
by: Nuno Magalhaes | last post by:
With the sniffer ethereal I get a lot of Connections Keep Alive in some sites like google.com and that returns me the Content-Length in the HTTP response header. When the connection is Close I...
3
10270
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...
10
3139
by: Steven Blair | last post by:
As I understand it, if I create a connection object in my application and close the connection, the next time I open a connection with the same connection string I should be using a pooled...
8
7842
by: Ike | last post by:
Is anyone aware of a means of connection pooling (to MySQL, say) in php? Thanks, Ike
8
1834
by: Joanna Carter [TeamB] | last post by:
Hi Folks I am just trying to get my head around whether I can use a single SQLConnection for the life of the application or whether I should create it only when needed. I want to create...
3
4875
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...
0
7167
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7208
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...
1
6890
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
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5464
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
4593
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3095
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1423
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
292
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.