Solved

ODBC and multithreading

Posted on 1999-01-26
2
364 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

837 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