Progress on ADODB.Connection Execute Call OR Timer

Is there any way to get the status back from a call to Execute off of a ADODB Connection?  This is a tall order I know but I thought I would ask.

If impossible, how do I get my timer control to fire so that I can update an elapsed time section in a status bar, like Query Analyzer?

I have implemented my timer like this:

Private ProcessStartTime datetime
Private bInProcess as boolean
Function Process()
   Dim conDB as New ADODB.Connecton

   conDB.Open ...

   bInProcess = True

   ProcessStartTime = Now()

   conDB.Execute "..."

   bInProcess = False

End Function

Private Sub tmrProgress_Timer()
   
    If bInProcess = True Then
        frmMain.stbrMain.Panels(4).Text =  Mid(CDate(Now() - ProcessStartTime), 4, 5)
    End If
   
End Sub
LVL 1
BruceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

onemorecokeCommented:
I dont think there is a way to get the progress back from an execute statement.  I had the same problem, and what I ended up doing was using an animated gif control.  I put the control on the form, started the animation, ran the execute, then stopped the animation afterwords.  True it does not give you a percentage complete or anything, but at least it gives something to the user to gaze at.  I can send you the animated gif files if this is an alternative for you.  They are written in VB so they are easy to integrate.  You will have to get an animated gif you want to use though.

Let me know

onemorecoke
0
Shiju SasidharanAssoc Project ManagerCommented:
Hi
well u want to
1 display time taken at the end of execution ?
2 or display elapsed time during process?


'========================
'if 1 is the case then  try this

Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
Function Process()
   Dim conDB as New ADODB.Connecton
  Dim lTime as Long

   conDB.Open ...
   
   lTime=GetTickCount
   conDB.Execute "..."
   lTime = GetTickCount - lTime
    Debug.Print "Total Time Taken=" & lTime & " Milliseconds"

    Debug.Print "Total Time Taken=" & lTime / 1000  & " Seconds"
    frmMain.stbrMain.Panels(4).Text =  lTime & " Milliseconds"
 
End Function



'========================
'if 2 is the case then  try this , Initailly keep timer as  Disabled

Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
Dim lTime as Long

Function Process()

   Dim conDB as New ADODB.Connecton
   conDB.Open ...
   lTime=GetTickCount
   tmrProgress.Enabled=True
   conDB.Execute "..."
   tmrProgress.Enabled=False

End Function
Private Sub tmrProgress_Timer()
   
       frmMain.stbrMain.Panels(4).Text =  ( GetTickCount - lTime )  & " Milli Seconds"
   
End Sub


;-)
Shiju

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leonstrykerCommented:
Depending on what you are executing, you could modify your code to Open an ADODB.Recordset which would contain a return code.

Leon
0
jkaiosIT DirectorCommented:
Use the "adAsyncConnect" constant as the fourth parameter to the "Open" method to open
the connection "asynchronously".  Because the default connection option is "adConnectUnspecified"
which is "synchronous" (all other subsequent codes are blocked after the process is completed), you cannot
implement the timer or any other codes after you call the ".Open" method until the method is completed.

So, here is how you call the Open method

---------------------------------------
conDB.Open , , , adAsyncConnect
---------------------------------------
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

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.