473,788 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
+ 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 1732
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*******@disc ussions.microso ft.com> wrote in message
news:5A******** *************** ***********@mic rosoft.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.Op en();
int i = myCommand.Execu teScalar();
myConnection.Cl ose
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*******@disc ussions.microso ft.com> wrote in message
news:5A******** *************** ***********@mic rosoft.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*******@disc ussions.microso ft.com> wrote in message
news:5A******** *************** ***********@mic rosoft.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********@com cast.nospam.net > wrote in message
news:e$******** ******@TK2MSFTN GP09.phx.gbl...
Paul...

if you have this code
myConnection.Op en();
int i = myCommand.Execu teScalar();
myConnection.Cl ose
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*******@disc ussions.microso ft.com> wrote in message
news:5A******** *************** ***********@mic rosoft.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******** ******@TK2MSFTN GP09.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********@com cast.nospam.net > wrote in message
news:e$******** ******@TK2MSFTN GP09.phx.gbl...
Paul...

if you have this code
myConnection.Op en();
int i = myCommand.Execu teScalar();
myConnection.Cl ose
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*******@disc ussions.microso ft.com> wrote in message
news:5A******** *************** ***********@mic rosoft.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_reservati on"
Vhistgrid.DataB ind(

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_reservati on"
Vhistgrid.DataB ind(

Thank
Paul.
Nov 18 '05 #8

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

Similar topics

1
314
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 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...
9
288
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 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...
6
392
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 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...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10118
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
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 we have to send another system

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.