Solved

ODBC: Connection is busy with results for another hstmt (#0)

Posted on 1998-03-02
9
2,051 Views
Last Modified: 2009-12-16
Hello,

I have a question that's dying for an answer.
I am a developer on a Access 2.0 & Sql Server 6.5 environment.

Lately, some of my users encountered a runtime error caused
by Microsoft Sql Server 6.5. The error doesn't occur consistently
or even frequently. Atleast untill yesterday. Since yesterday the
error occurs frequently, making the problem urgent.

The error:
ODBC-call failed. [Microsoft][ODBC SQL Server Driver] Connection is
busy with results for another hstmt [#0]

After some investigating on Microsoft Technet, I learned that this could
be caused by the way Sql Server handles PassThrough-queries. It can
only handle one PassThrough-statement at a time.

The funny thing is that the code, where-ever the errors occur, doesn't
contain PassThrough: Just plain Jet-engine selects and updates.

I also found that Virus-checkers may be the cause. Due to the checking
of all results, the time out may occur, in conjunction with the Times to try.

If you have any (good) ideas, please let me know. I am not expecting a
complete answer, just directions.

Jeroen.

0
Comment
Question by:JeroenW
  • 3
  • 3
  • 3
9 Comments
 
LVL 1

Author Comment

by:JeroenW
ID: 1090407
Edited text of question
0
 
LVL 2

Expert Comment

by:alokm
ID: 1090408
it seems to me that u are trying to do too many selects/updates on a single connection at a time.
i think u should open separate connection for updates.
0
 
LVL 2

Expert Comment

by:alokm
ID: 1090409
maybe the the first select's recordset object is not fully populated and then the update goes. That will give such errors. To remove this on the recordset do a movelast so that it gets fully populated and then give the other statement.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 1

Author Comment

by:JeroenW
ID: 1090410
Dear Alokm,

Thanks for the comment. The sollution your giving is like the one Microsoft supplies:
Use a movelast to get the entire result from Sql Server.
This sollution works only for passThrough-queries (Microsoft says; please let me know if this MS comment is wrong, I have a lot of recordsets open at the time, but the problem didn't occur in the past while the code was pretty much the same).

I also have thought of your sollution, but reducing the open recordsets didn't supply the answer. Also, the errors didn't appear at the same place, which leads me to think it is something wrong in the settings.

Thanks,

Jeroen Westera

0
 
LVL 2

Expert Comment

by:alokm
ID: 1090411
If it was working perfectly in the past , then i think the load on the server has increased because of maybe more users, more extensive requests and more locks on the tables.
0
 
LVL 2

Expert Comment

by:Jim_SQL
ID: 1090412
Hi,

Is this happening when using MS Access directly (no code), or is it happening when you pass SQL statements through VB (or another langauge) using ODBC/RDO/... code?

Jim

0
 
LVL 2

Expert Comment

by:Jim_SQL
ID: 1090413
Hi,

Is this happening when using MS Access directly (no code), or is it happening when you pass SQL statements through VB (or another langauge) using ODBC/RDO/... code?

Jim

0
 
LVL 2

Accepted Solution

by:
Jim_SQL earned 200 total points
ID: 1090414
Hi (again),

I'm going to assume it's through code (ODBC... or what ever). This would mean that the connections aren't being cleaned out. When you (or the programmers) get a result set they have to walk through every record AND RECORD SET. There may be 3 record sets each having multiple records and each one has to be accounted for (either by walking through each record and then through each record set, or by moving last in each record set, and then through each record set or by simply canceling the result sets.)
(Be carefull of aggregate functions.)

'Put the statement into the command buffer.
Result% = SqlCmd%(Sqlconn%, "SELECT data FROM table")
'Send the statement to SQL Server and start execution.
Result% = SqlExec%(Sqlconn%)
DO UNTIL Result% = NOMORERESULTS    'Process the statement results.
   Result% = SqlResults%(Sqlconn%)

   'Retrieve and process the data in each row.
   DO UNTIL SqlNextRow%(Sqlconn%) = NOMOREROWS
      'Code to print or process row of data.
   LOOP
LOOP

(This is sample code from books on line for "SqlResults%")

... I'd bet that someone has changed the query so that now it can return more than 1 result set....

P.S. My experience is mainly with VB through ODBC/RDO (i.e. my comments may not apply...?).

(Hope this helps.)
Jim

0
 
LVL 1

Author Comment

by:JeroenW
ID: 1090415
Hi Jim,

Thanks for your answer. The cancelling of the result-set (or rerunning all queries) works, but it is a lot of work as the errors occur in several parts of the application. It doesn't do good things for performance either.

Instead I've implemented a piece in each errorhandling routine:
if err = 3146 then 'the connection busy error...
  resume next
else
  ' the normal handling.
endif

I know it is not the most beautiful way, but at least the users can
continue making their bills, claims etc. I will stay on the lookout
for better sollutions.

Thanks again Jim

To alokm:
Thanks for your comments. There has been an increase in users
and the network-traffic increased even more. I am looking in to
reducing the traffic.

Greetings,

Jeroen.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Activity Monitor detail 2 28
What is the best way to use power bi and ssrs 3 27
SQL 2008 R2 problem with DB 9 18
Loops in SQL server code 4 22
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question