473,326 Members | 2,081 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,326 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 1691
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.