Asynchronous ADO and DCOM

Firstly, I am trying to get 5 (or more) threads in one process to connect (and eventually execute) asynchronously to an SQL Server (7 Beta 3) under VB5. The first one connects, but the others all sit aroiund and take up CPU. If I only have one thread in the process, it connects just fine and does not eat up CPU. How can I get many asynchronous threads working in the same process?

Secondly, when this single thread connects, I perform the async execute, and I want to return the data to another process (via DCOM). When ExecuteComplete is called, I use a
callback to comminucate with the other process, but it waits until the whole recordset is available i.e. all 5000 records are returned to executing thread. How can I return to the client process the recordset before it is complete?
Who is Participating?

Improve company productivity with a Business Account.Sign Up

wizard2072098Connect With a Mentor Commented:
Contrary to popular demand, you CAN create multiple threads in VB5/VB6. You just can't DEBUG them very easily in the VB IDE. Everything you've ever wanted to know about multithreading in VB can be found in the MSDN in an article entitled "Ingenious Ways to Implement Multiple Threads in Visual Basic 5.0" by John Robbins. If you don't have the MSDN, get on the MSDN on and read it there.

He gives examples, too.
i don't know the answer to your question but i would like to see the code for getting the 5 or more threads in one process. can you please post your code?

as for the first part: you don't have control over thread creation in VB. you can initiate new child processes and control them using ActiveX EXE, but they will work in another process.

as for the second part: the async execute is notifyable only when a query is a really long time execution maker, and only when the server can send back some data before it finishes the query execution. for example: GROUP BY queries need to run through the whole query before any records are returned, as well as sorted queries (no always).
the async is in the context of execution and not in the context of the network traffic (although it be better if such a feature would exist) and a 5000 records query certainly does not seem to consume to much of any of them (although it might if these are summaries in a gouped query, in which case the begining of the answer applies)
fredforsythAuthor Commented:
Sorry, i didn't mention that I'm using ADO to talk to the database. Basically, is it possible to use ADO with events in separate threads in a process?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.