Solved

ODBC and multithreading

Posted on 1999-01-26
2
365 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

696 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