Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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). CPU's flags not checked

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

like image 744
ienax_ridens Avatar asked Jan 26 '12 11:01

ienax_ridens


3 Answers

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
like image 180
grenadejumper Avatar answered Sep 21 '22 13:09

grenadejumper


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.

like image 9
Devart Avatar answered Sep 18 '22 13:09

Devart


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.

like image 2
dataol Avatar answered Sep 22 '22 13:09

dataol