为什么只有部分用户会收到错误:“连接正忙于处理另一个命令的结果"?

我有一个使用 DevArt 的 SDAC 组件连接到 SQL Server 数据库的 Delphi 应用程序,我们安装了 200 次该软件,并且只安装给一个客户,有一些用户,我注意到以下错误:

I have a Delphi Application that is connected to a SQL Server db using SDAC component from DevArt, we have 200 installations of the software and only to a customer, with some users, I notice the following error:

"Connection is busy with results for another command" = "La connessione è occupata dai risultati di un altro comando".

SQL 版本:启用文件流完全功能的 SQL Server 2008 R2 Express

SQL vers.: SQL Server 2008 R2 Express with filestream full enabled

我的应用程序同时创建 db 用户和 SQL 帐户登录:

My application create both db users and SQL account logins:

  1. 创建一个新用户,然后就没有问题了
  2. 在我的应用程序中更改用户代码,这意味着创建了另一个 db 用户和 SQL 帐户登录,我有错误
  3. 这个问题只发生在部分用户身上,而不是所有用户身上

我已经尝试过但没有运气:

What I've already tried without luck:

  1. 删除并重新安装数据库
  2. 卸载并重新安装 SQL Server 实例
  3. 已检查 SQL Server 中的用户/帐户属性(一切正常)

如果您需要具体信息,请告诉我

If you need specific infos please tell me

------------新信息------------

------------NEW INFORMATIONS------------

我更好地检查了 Studio Management 中的所有实例属性,我注意到 CPU 没有被检查(见下图).

I checked better all the Instance properties from Studio Management and I've noticed that CPU's are not checked (see image below).

在 SQL Server 的所有其他正常安装中,我看到已填充的复选框.会不会是问题?

Instead in all the other normal installations of SQL Server, I see filled checkboxes. Could it be the problem?

我希望这能帮助你帮助我......

I hope this help you to help me...

推荐答案

Connection is busy with results for another command"错误意味着至少有两个查询使用相同的连接.如果您在多个线程中使用一个连接,则可能会出现此问题.要解决这种情况下的问题,您应该在每个线程中都有连接(TMSConnection 组件).此外,如果将 TCustomMSDataSet.FetchAll 属性设置为 False,也会出现此问题.当 FetchAll=False 时,执行此类查询会阻止当前会话.为了避免阻塞 OLEDB 创建可能导致连接正忙于处理另一个命令的结果"错误的额外会话.要解决这种情况下的问题,您应该将 TMSConnection.Options.MultipleActiveResultSets 属性设置为 True.MultipleActiveResultSets 属性支持 SQL Server 多活动结果集 (MARS) 技术.它允许应用程序在每个连接中有多个待处理的请求,特别是每个连接有多个活动的默认结果集.请注意,MultipleActiveResultSets 属性仅在使用 SQL Native Client 时有效.因此,您还应该将 TMSConnection.Options.Provider 属性设置为 prNativeClient.

The "Connection is busy with results for another command" error means that there are at least two queries that use the same connection. This problem can occur if you are using one connection in several threads. To solve the problem in this case, you should have connection (the TMSConnection component) in each thread. Also, this problem can occur if you set the TCustomMSDataSet.FetchAll property to False. When FetchAll=False, execution of such queries blocks the current session. In order to avoid blocking OLEDB creates additional session that can cause the "Connection is busy with results for another command" error. To solve the problem in this case, you should set the TMSConnection.Options.MultipleActiveResultSets property to True. The MultipleActiveResultSets property enables support for the SQL Server Multiple Active Result Sets (MARS) technology. It allows applications to have more than one pending request per connection, and, in particular, to have more than one active default result set per connection. Please note that the MultipleActiveResultSets property works only when SQL Native Client is used. Therefore, you should also set the TMSConnection.Options.Provider property to prNativeClient.

相关文章