473,472 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What could cause left open SQL data connection

Hi just wondering what could cause a left open SQL connection as this has only occured 2 times in the last week. The error it creates is when a web app tries to open a connection an error message states, it is already open. The process was then killed to close the connection. The usage is pretty low around 15 workstations. Looking at the code it appears that all connections get closed, so thinking it is not a problem with the code. Thanks Paul.
Nov 18 '05 #1
7 1702
Are you calling the .close method of the connection or just killing the
process? Killing the process won't close the ADO.NET SQLConnection object.

You should have your .open method in a Try...Catch and the .close method in
the Finally.
"Paul" <an*******@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
Hi just wondering what could cause a left open SQL connection as this has

only occured 2 times in the last week. The error it creates is when a web
app tries to open a connection an error message states, it is already open.
The process was then killed to close the connection. The usage is pretty
low around 15 workstations. Looking at the code it appears that all
connections get closed, so thinking it is not a problem with the code.
Thanks Paul.
Nov 18 '05 #2
Paul...

if you have this code
myConnection.Open();
int i = myCommand.ExecuteScalar();
myConnection.Close
and you raise an exception, you'll never hit close so I'd check that first,
and move my close statements to Finally blocks. I'm guessing that's the
problem. If not, let me know.

Bill
"Paul" <an*******@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
Hi just wondering what could cause a left open SQL connection as this has

only occured 2 times in the last week. The error it creates is when a web
app tries to open a connection an error message states, it is already open.
The process was then killed to close the connection. The usage is pretty
low around 15 workstations. Looking at the code it appears that all
connections get closed, so thinking it is not a problem with the code.
Thanks Paul.
Nov 18 '05 #3
It's definitely a problem with the code. It sounds like some developer is
playing around with re-using Connections in your app. Not a good practice in
..Net.

General rule of thumb: Open a Connection when you need it, use it, Close it
as soon as you're done with it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Paul" <an*******@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
Hi just wondering what could cause a left open SQL connection as this has

only occured 2 times in the last week. The error it creates is when a web
app tries to open a connection an error message states, it is already open.
The process was then killed to close the connection. The usage is pretty
low around 15 workstations. Looking at the code it appears that all
connections get closed, so thinking it is not a problem with the code.
Thanks Paul.
Nov 18 '05 #4
Didn't think of that! Excellent suggestion!

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
Paul...

if you have this code
myConnection.Open();
int i = myCommand.ExecuteScalar();
myConnection.Close
and you raise an exception, you'll never hit close so I'd check that first, and move my close statements to Finally blocks. I'm guessing that's the
problem. If not, let me know.

Bill
"Paul" <an*******@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
Hi just wondering what could cause a left open SQL connection as this
has only occured 2 times in the last week. The error it creates is when a web
app tries to open a connection an error message states, it is already open. The process was then killed to close the connection. The usage is pretty
low around 15 workstations. Looking at the code it appears that all
connections get closed, so thinking it is not a problem with the code.
Thanks Paul.

Nov 18 '05 #5
Agreed. I read that post and was like, holy cow I need to check my code!

Thanks Bill!

- Chad
"Kevin Spencer" <ke***@takempis.com> wrote in message
news:uX**************@TK2MSFTNGP09.phx.gbl...
Didn't think of that! Excellent suggestion!

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
Paul...

if you have this code
myConnection.Open();
int i = myCommand.ExecuteScalar();
myConnection.Close
and you raise an exception, you'll never hit close so I'd check that

first,
and move my close statements to Finally blocks. I'm guessing that's the
problem. If not, let me know.

Bill
"Paul" <an*******@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
Hi just wondering what could cause a left open SQL connection as this has
only occured 2 times in the last week. The error it creates is when a

web app tries to open a connection an error message states, it is already

open.
The process was then killed to close the connection. The usage is pretty low around 15 workstations. Looking at the code it appears that all
connections get closed, so thinking it is not a problem with the code.
Thanks Paul.


Nov 18 '05 #6
ok thanks for the responses. This is code that someone else developed and I have modified
I did add a section of code that uses a data connection, data adapter, and a dataset. It calls a stored procedure on the server. I did not use open or close in the code but it seemed to be working ok. The stored procedure pulls data from a few tables and displays it on the data grid
Do I need to implicitly use the open and close statements for the connection or data adapter for this or does the fill automatically open the connection and then close it

SqlDataAdapter1.Fill(ds_vhist, "dbo_pg_parmsel_past_reservation"
Vhistgrid.DataBind(

Thank
Paul.
Nov 18 '05 #7
ok thanks for the responses. This is code that someone else developed and I have modified
I did add a section of code that uses a data connection, data adapter, and a dataset. It calls a stored procedure on the server. I did not use open or close in the code but it seemed to be working ok. The stored procedure pulls data from a few tables and displays it on the data grid
Do I need to implicitly use the open and close statements for the connection or data adapter for this or does the fill automatically open the connection and then close it

SqlDataAdapter1.Fill(ds_vhist, "dbo_pg_parmsel_past_reservation"
Vhistgrid.DataBind(

Thank
Paul.
Nov 18 '05 #8

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

Similar topics

1
by: Paul | last post by:
Hi just wondering what could cause a left open SQL connection as this has only occured 2 times in the last week. The error it creates is when a web app tries to open a connection an error message...
9
by: Paul | last post by:
Hi just wondering what could cause a left open SQL connection as this has only occured 2 times in the last week. The error it creates is when a web app tries to open a connection an error message...
6
by: Paul | last post by:
Hi just wondering what could cause a left open SQL connection as this has only occured 2 times in the last week. The error it creates is when a web app tries to open a connection an error message...
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...
1
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
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
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.