Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 392
  • Last Modified:

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
0
Bruce
Asked:
Bruce
1 Solution
 
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
 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now