
Recordsaffected during async execute
Bart,
The only time I've had problems w/ ExecuteComplete event not firing (even
for short executions) is when I have something blocking, like stepping
through the code, or a breakpoint right after I execute the command. When
this happens, the event handler will not run -- I've even placed break
points in the ExecuteComplete event handler in this circumstance; it just
doesn't run, like something about the IDE blocks the interception of the
event?. Anyway, first make sure there is nothing (like break point, etc.)
that might block.
Next, I'm a little confused...you said you don't want to use "DoEvents" but
then your code-slice shows it. I haven't used DoEvents much in my code, but
maybe this is causing the problem? Your line:
Quote:
> While (acmProcess.State = adStateExecuting)
> DoEvents
> Wend
seems redundant since you are already executing asynchronously.
HTH,
Simon Taylor
Resource Data, Inc.
Quote:
> Hello,
> I'm running an asynchronously command execute and I want to get the number
> of records affected. The connection is a 'withevents' connection.
> The code is as follows.
> Dim acmProcess As New ADODB.Command
> Set acmProcess.ActiveConnection = cnProduction
> acmProcess.CommandType = adCmdStoredProc
> acmProcess.CommandText = "[Copy MyData To History]" 'This is an
> Existing INSERT INTO Query in an Access 97 Database
> acmProcess.Execute , , adAsyncExecute
> While (acmProcess.State = adStateExecuting)
> DoEvents
> Wend
> According to ADO Help the Event ExecuteComplete should be triggered when
> execution is complete. This does happen if there is a large number of
> records to insert but not for small numbers.
> Since the ExecuteComplete Event returns the number of records affected for
> Asynchronously Executes, I need a way to get to the smaller numbers.
> I've also used the normal (synchronously) execute (acmProcess.Execute
> lRecordsAffected). This does return the smaller numbers, but at large
> numbers I have to wait a long time before the system is 'free' again (No
> DoEvents).
> Can anyone tell me the proper solution to this problem.
> Thanks in advance,
> Bart