Why only some users get the error: “Connection is busy with results for another command”

流过昼夜 提交于 2019-12-04 12:01:42

问题


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 vers.: SQL Server 2008 R2 Express with filestream full enabled

My application create both db users and SQL account logins:

  1. creating a new user, then there aren't problems
  2. changing user code in my application, it means that another db user and SQL account login is created, I have the error
  3. this problem happens only with some users, not all ones

What I've already tried without luck:

  1. deleted and re-installed database
  2. uninstalled and re-installed SQL Server Instance
  3. checked users/account properties in SQL Server (all ok)

If you need specific infos please tell me

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

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

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...


回答1:


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.




回答2:


Just wanted to correct dataol's answer and say that MARS_Connection should be set to "Yes" instead of "True" to enable Multiple Active Result Sets. At least on SQL Server 2012 if you are using a DSN file:

[ODBC]
DRIVER=SQL Server Native Client 11.0
DATABASE=MYDBNAME
WSID=
Trusted_Connection=Yes
SERVER=
MARS_Connection=Yes



回答3:


To provide Multiple Active Result Set (MARS) support to a SQL connection using the MSSQL driver, you must add a key called Mars_Connection and set its value to True.




回答4:


I had the same problem and solved installing the microsoft odbc driver 11 (msodbcsql) (https://www.microsoft.com/pt-br/download/confirmation.aspx?id=36434).




回答5:


@ienax_ridens, I recently encountered the same problem using the same tools (Delphi and Devart-SDAC). In my case one specific query giving two results sets. My TMSQuery was

If Condition= 1 
begin
 Select * from #TempTable1
end else 
begin
  -- Some more stuff
  Insert INTO #TempTable2
 --
 --
End
Select * from TempTable1 -- here is the problem

so in case of Condition = 1 it was giving two results sets and causing "Connection is busy with results for another command"

I hope this helps you.

Edit: I realized you post is quite old, please share what you did to resolve this error



来源:https://stackoverflow.com/questions/9017264/why-only-some-users-get-the-error-connection-is-busy-with-results-for-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!