【问题标题】:TADOConnection.Close - connection still active on MS-SQL serverTADOConnection.Close - MS-SQL 服务器上的连接仍处于活动状态
【发布时间】:2018-02-09 12:02:07
【问题描述】:

我有几个 Delphi 程序 (XE3),它们使用 TADOConnection 连接到 MS-SQL Server。 我最近检查了“MS SQL Server Management Studio”进程列表中的连接。

  • 程序启动时,连接处于非活动状态,没有连接 服务器的进程列表。
  • 当我打开连接时,它会显示在进程列表中 - 如 预计。
  • 当我关闭连接时(绝对是“已连接”属性 返回 FALSE),连接仍显示在服务器进程上 列表。

在我关闭程序之前,服务器上的连接不会关闭。

有没有办法在不退出程序的情况下真正删除服务器上的连接来关闭 TADOConnection?

【问题讨论】:

  • 看起来像正常的连接池行为。我希望物理连接会在几分钟不活动后关闭。

标签: sql-server delphi ado


【解决方案1】:

这是连接池;而且是件好事。

但如果您真的想降低性能,您可以通过将请求添加到您的连接字符串来选择退出连接池功能:

Provider=SQLOLEDB;Data Source=myServerAddress;Initial Catalog=myDataBase;
User ID=myUsername;Password=correct horse battery stapler;OLE DB Services=-2;

这些 OLE DB Services 选项记录在 MSDN 上:

Pooling in the Microsoft Data Access Components (archive)

OLE DB Services  Services enabled
===============  ==================================================
-1               All services (the default)
-2               All services except pooling
-4               All services except pooling and auto-enlistment
-5               All services except client cursor
-6               All services except client cursor and pooling
 0               No services

【讨论】:

  • 非常感谢赐教!现在我知道,我可以忽略这些,因为它们不是糟糕的编程的理由。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-15
  • 2016-12-19
  • 2012-01-03
  • 2021-09-13
  • 2013-08-27
  • 2019-09-01
相关资源
最近更新 更多