473,387 Members | 1,425 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,387 software developers and data experts.

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 1697
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.