Solved

Asynchronous ADO and DCOM

Posted on 1998-11-17
4
345 Views
Last Modified: 2013-12-25
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?
0
Comment
Question by:fredforsyth
4 Comments
 
LVL 3

Expert Comment

by:vmano
ID: 1497702
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?

thanks
vmano
0
 
LVL 1

Expert Comment

by:zivf
ID: 1497703
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)
0
 
LVL 1

Accepted Solution

by:
wizard2072098 earned 100 total points
ID: 1497704
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 microsoft.com and read it there.

He gives examples, too.
0
 

Author Comment

by:fredforsyth
ID: 1497705
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?
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

810 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