[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ODBC and multithreading

Posted on 1999-01-26
2
Medium Priority
?
373 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 800 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

834 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