[posted and mailed, please reply in news]
vishal (vi**************@mentorix.com) writes:
I am having multiple threads in my c program to execute same procedure
with differnt parameter values every time.
I have created different functions to execute the same.
However when SQLExecute is run on one of the thread it returns an
error saying
[Microsoft][ODBC SQL Server Driver]Connection is busy with results for
another hstmt
How do I call the same stored procedure on different threads to
execute at the same time.
It has nothing to do with that you are calling the same procedure in
different threads. It has to do with that you are trying to use the
same connection for simulataneous requests.
The most common reason for this error is a failure to get all rows and
result sets from the server. This could be because you have not anticipated
extra result sets generated by "rows affected" messages. These messages can
be turned off with SET NOCOUNT ON, and this is usually a good practice to
do, because it improves performance. (Of course, sometimes you need these
messages, in which case you should keep NOCOUNT off.)
If you are accessing SQL Server from separate threads, each thread should
probably have its own connection. If not, the connection is a common
resource, and the threads must use a semaphore or some other locking
mechanism, to be able to access the common resource.
--
Erland Sommarskog, SQL Server MVP,
es****@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp