Solved

ODBC and multithreading

Posted on 1999-01-26
2
362 Views
Last Modified: 2012-06-22
I am attempting to use a single CDatabase object across two threads.  I have two different CRecordSet objects that are instantiated on the stack of each thread.  The thread that hits the CRecordSet::Open command first is fine.  The second thread throws a CDBException with the message:
"Connection is busy with results for another hstmt".  The message appears to come from the ODBC driver itself.  (SQL Server)  I DO NOT wish to instantiate multiple CDatabase objects for each thread.  How do I get around this?
0
Comment
Question by:mozack
2 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 1185213
You have to synchronize _each_ ODBC call for every thread...
0
 

Accepted Solution

by:
erick1217 earned 200 total points
ID: 1185214
U need to use the same "CDatabase" object pointer in each thread and then synchronise them with a "CMutex" object or with "CreateEvent" and "WaitForSingleObject".
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

777 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