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 us
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
.
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
@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
Check your compatibility mode i just ran into this when we moved from 2008 to 2016 db we had to set it to 2012 compatibility mode.
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.
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).