Recordsaffected during async execute 
Author Message
 Recordsaffected during async execute

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



Tue, 07 Sep 2004 21:13:15 GMT  
 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



Wed, 08 Sep 2004 07:48:45 GMT  
 Recordsaffected during async execute
I can reproduce the effect using Event Monitoring in AdoAnywhere on
recordsets. Can't tell you why it happens but Async events on recordsets
consistently fails on small table.

--
Michael Collier Bsc (Hons)

Interactive ADO Browser Trial  www.adoanywhere.com/cnet
Free ADO Browser (FAB)  www.adoanywhere.com/fab
Home Page www.adoanywhere.com

--


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



Wed, 08 Sep 2004 12:21:04 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. asp - .execute RecordsAffected parameter

2. RecordsAffected Property = 0 After Update Query Executed

3. ADO Execute Async

4. ADO And Async Execute

5. Async Execute

6. Executing a string as a VB cmd during runtime

7. Form_load executing during shutdown

8. Executing a function during runtime

9. Executing a function() during runtime

10. ocx code executes during vbg compilation ! (VB6)

11. Visual Studio Installer -- Custom .exe file to be executed during installation

12. RecordsAffected problems giving wrong numbers

 

 
Powered by phpBB® Forum Software