Global SQLConnection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having some problems with a Windows Service application that uses a
global SQLConnection that is opened when the service starts and closed only
when the service terminates.

I realise this is not too good and am planning to change it, however I just
wanted to know if this could cause the connection to just close on it's own
after a certain amount of time and/or volume (i.e. without being explicitly
closed). It seems to only happen when alot is going on with the app and
database itself (several other apps access the same database) and resources
on the server are scarce. I have had instances where the problem disappears
when the client upgrades their server, probably not a good long term solution.

Thanks in advances for any thought.

Regards,
Isaac Taylor
 
Isaact,

Not that I ever used it in this context. What is bad at your solution
(assuming it is the only one for your database actions for all your
applications). Your only problem is that if somebody for whatever reason
brings the server down, you have to catch that to close the connection and
reopen that again.

This can be a reason to open and close your connection with every to execute
command (or transaction which I assume that you use) which is a lot easier
and surely saver.

Just my thought,

Cor
 
It shouldn't drop the connection for no reason - apparently there is
something going on either on the network or the server.
Here are my suggestions:
- you should open as late as possible and close connection as soon as
possible
- in the case of connection failure, you should reopen the connection using
the connection string + space char - you will force connection pool to
create a new physical connection for you
 
¤ I am having some problems with a Windows Service application that uses a
¤ global SQLConnection that is opened when the service starts and closed only
¤ when the service terminates.
¤
¤ I realise this is not too good and am planning to change it, however I just
¤ wanted to know if this could cause the connection to just close on it's own
¤ after a certain amount of time and/or volume (i.e. without being explicitly
¤ closed). It seems to only happen when alot is going on with the app and
¤ database itself (several other apps access the same database) and resources
¤ on the server are scarce. I have had instances where the problem disappears
¤ when the client upgrades their server, probably not a good long term solution.
¤

It depends on the database you are using. It is possible in some database server systems (such as
Oracle) to terminate connections that remain open and unused for a specified period of time.

However, it's probably more likely that the network connection is dropping, which is why I wouldn't
advise using persistent connections.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
This problem will go away once you wean your application from a global
SqlConnection instance.
 
Oh and thanks for your mailing address too .. I'll come over for coffee
sometime :-)
 
Back
Top