Sql Connection。清除所有池与Ole DbConnection。释放对象池 [英] Sql​Connection.​Clear​All​Pools vs Ole​DbConnection.​Release​Object​Pool

查看:132
本文介绍了Sql Connection。清除所有池与Ole DbConnection。释放对象池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先:两个函数之间有什么区别?


参见msdn:
Ole DbConnection。Release Object Pool-Method
 和
Sql Connection。清除所有池 - 方法


其次,我们的ERP程序需要获得对一个SQL-Server数据库的独占访问权限。对于我们在程序中的连接,我们关闭连接,但在关闭它们之前,我们执行"USE master",因此将
返回到连接池并不代表问题。但我们也使用第三方模块(Crystal Reports for VS),它也打开和关闭SQL连接:这里我们确定连接已在最后关闭,连接返回到
连接池并且我们必须等待超过一分钟才能摆脱那个连接。


我试过了两个  Release Object Pool和清除所有池,但关闭的连接不会从池中删除。


BTW。 Crystal Reports连接(2016)使用 "Microsoft OLE DB Provider for SQL Server"。


Crystal Reports还有一篇知识库文章:

2107357 - 当查看器对象为时,Windows.Form Viewer不会与数据库断开连接关闭/无效


任何想法?


Patrick

解决方案

嗨帕特里克,


感谢您的提问。


根据您的描述,我知道您对连接有疑问在执行方法"Release Object Pool","Clear All Pools"之后,不会从池中删除。基于此,出现这种情况的唯一原因是连接
仍在使用中,或者客户端应用程序和其他人已在池中建立了新的连接。


所以我们需要使用一些相关的动态管理视图或工具来监控和测试它。


最好的问候,



First: what is the difference between the 2 functions?

see Msdn: Ole​DbConnection.​Release​Object​Pool-Method and Sql​Connection.​Clear​All​Pools-Method

Secondly we have a situation where our ERP-program needs to get exclusive access to one SQL-Server database. For our connections inside our program we close the connections, but before closing them we execute a "USE master", so returning them to the connection pool doesn't represent a problem. But we also use a 3rd party module (Crystal Reports for VS) which also opens and closes SQL connections: here we are sure that the connection has been closed at the end, the connection returns to the connection pool and we have to wait over one minute to get rid of that connection.

I tried both Release​Object​Pool and Clear​All​Pools, but the closed connection isn't dropped from the pool.

BTW. the Crystal Reports connections (2016) use the "Microsoft OLE DB Provider for SQL Server".

Crystal Reports has also an KB article:
2107357 - Windows.Form Viewer does not disconnect from the Database when the viewer object is close/Null

Any ideas?

Patrick

解决方案

Hi Patrick,

Thanks for your question.

Per your description, I know that you have doubts that the connection isn't removed from the pool after executing the methods "Release​Object​Pool", "Clear​All​Pools". Based on this, the only reason for such situation is that the connection is still in use, or that client application and others have established a new connection in the pool.

So we need to use some related dynamic management views or tools to monitor and test that.

Best Regards,

Will


这篇关于Sql Connection。清除所有池与Ole DbConnection。释放对象池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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