borderAndreaVB free resources for Visual Basic developersborder
AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2017 Andrea Tincani
:: Run a Stored Procedure Asynchrous with ADO

Author  

Mike G

Language  

VB5, VB6

Operating Systems  

Windows 95,98,NT
Tip

'Sometimes you have stored proc that takes 2,3 or 5 min to execute.
'Application that lock up frequently frustrates users and waste their time and resources.
'Solution use ADO ASYNCHROUS OPTION to get back CPU resorces.

Public Sub ExecuteAsync()
    Dim cmd As ADODB.Command
   
    Set cmd = New ADODB.Command
    cmd.ActiveConnection = "DSN=test"
    cmd.CommandTimeout = 180
    cmd.CommandText = "sp_name"
    cmd.CommandType = adCmdStoredProc
    cmd.EXECUTE , , adAsyncExecute
'<--- start ASYNCHROUS
    'You can also make a dumy progress bar  to show proggres

   
    Do While (cmd.State And adStateExecuting) = adStateExecuting
       DoEvents
    Loop
   
    'Methods Options
    'EXECUTE adAsyncExecute, adAsyncFetch
    'OPEN adAsyncConnect
   
    'You can do same this with RDO
   
    'Do While rs.StillExecuting
    '    DoEvents
    'Loop

End Sub

:: Navigation

Home

Database Management

Previous Tip

Next Tip

:: Search this site
Google
borderAndreaVB free resources for Visual Basic developersborder
borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2017 Andrea Tincaniborder