什么可能导致左开SQL数据连接 [英] What could cause left open SQL data connection

查看:66
本文介绍了什么可能导致左开SQL数据连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您只是想知道什么可能导致左开SQL连接,因为它在上周只发生了2次。它创建的错误是当Web应用程序尝试打开连接时出现错误消息,它已经打开。然后杀死该过程以关闭连接。大约15个工作站的使用率非常低。看代码看起来所有连接都被关闭了,所以认为它不是代码的问题。谢谢Paul。

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.

推荐答案

你是在调用连接的.close方法还是只是杀死了

进程?杀死进程不会关闭ADO.NET SQLConnection对象。


你应该在Try ... Catch和.close方法中使用.open方法。 >
the Finally。

" Paul" <一个******* @ discussions.microsoft.com>在消息中写道

新闻:5A ********************************** @ microsof t.com ...
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...
您只是想知道什么可能导致左侧打开SQL连接,因为它有
Hi just wondering what could cause a left open SQL connection as this has



仅在上周发生了2次。它创建的错误是当一个web

应用程序尝试打开连接时出现错误消息,它已经打开。

然后该进程被终止以关闭连接。大约15个工作站的使用率非常低。看一下代码,看来所有的

连接都关闭了,所以认为这不是代码的问题。

谢谢保罗。


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.


Paul ...


如果你有这个代码

myConnection.Open();

int i = myCommand.ExecuteScalar();

myConnection.Close

然后你提出异常,你永远不会打到关闭所以我先检查一下,

并将我的close语句移动到Finally块。我猜这是'

问题。如果没有,请告诉我。


比尔

" Paul" <一个******* @ discussions.microsoft.com>在消息中写道

新闻:5A ********************************** @ microsof t.com ...
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...
您只是想知道什么可能导致左侧打开SQL连接,因为它有
Hi just wondering what could cause a left open SQL connection as this has



仅在上周发生了2次。它创建的错误是当一个web

应用程序尝试打开连接时出现错误消息,它已经打开。

然后该进程被终止以关闭连接。大约15个工作站的使用率非常低。看一下代码,看来所有的

连接都关闭了,所以认为这不是代码的问题。

谢谢保罗。


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.


这肯定是代码的问题。听起来有些开发人员在你的应用程序中重复使用Connections。不是很好的练习

..Net。


一般经验法则:在需要时打开一个连接,使用它,关闭它




-

HTH,

Kevin Spencer

..Net开发人员

微软MVP

大的东西组成

很多小东西。


" Paul" <一个******* @ discussions.microsoft.com>在消息中写道

新闻:5A ********************************** @ microsof t.com ...
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...
您只是想知道什么可能导致左侧打开SQL连接,因为它有
Hi just wondering what could cause a left open SQL connection as this has



仅在上周发生了2次。它创建的错误是当一个web

应用程序尝试打开连接时出现错误消息,它已经打开。

然后该进程被终止以关闭连接。大约15个工作站的使用率非常低。看一下代码,看来所有的

连接都关闭了,所以认为这不是代码的问题。

谢谢保罗。


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.


这篇关于什么可能导致左开SQL数据连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆