473,403 Members | 2,366 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,403 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 1698
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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
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
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.