Solved

ODBC and multithreading

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now