developer155
Programmer
I have this code that I use to get the result from a call to stored proc. When the stored proc returns something, I go on with the program. The problem is that sometimes this goes to a infinite loop ( I run it with the same data as with time when it exits fine). What could be the bottleneck here? I am providing all the functions used. The first code is where the loop happens
Dim sEventDate as String
Dim rsCheckFinishEvent as ADODB.Recordset
While sEventDate = ""
Set rsCheckFinishEvent = gADOGetRecordset_RW("exec spCAP_GetFinishEvent " & sAdID)
If Not rsCheckFinishEvent.EOF Then
rsCheckFinishEvent.MoveFirst
sEventDate = rsCheckFinishEvent!fEventDate
Set rsCheckFinishEvent = Nothing
Else: Pause (5000)
End If
Wend
------------------------------------
Public Function Pause(Value As Long)
Dim PreTick As Long
PreTick = GetTickCount
Do
DoEvents
If GetTickCount = PreTick + Value Then Exit Do
Loop
End Function
------------------------
Public Function gADOGetRecordset_RO(szSP As String, Optional bolReturnError As Boolean = False) As ADODB.Recordset
Dim objRecordSet As New ADODB.Recordset
Dim intCount As Integer
Dim bErrorRaised As Boolean
Dim nErrNumber As Long
Dim szErrDesc As String
On Error GoTo HandleError:
With objRecordSet
.CacheSize = 500
.ActiveConnection = gudProfile.adoConnection
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Source = szSP
.Open
Exit Function
Dim sEventDate as String
Dim rsCheckFinishEvent as ADODB.Recordset
While sEventDate = ""
Set rsCheckFinishEvent = gADOGetRecordset_RW("exec spCAP_GetFinishEvent " & sAdID)
If Not rsCheckFinishEvent.EOF Then
rsCheckFinishEvent.MoveFirst
sEventDate = rsCheckFinishEvent!fEventDate
Set rsCheckFinishEvent = Nothing
Else: Pause (5000)
End If
Wend
------------------------------------
Public Function Pause(Value As Long)
Dim PreTick As Long
PreTick = GetTickCount
Do
DoEvents
If GetTickCount = PreTick + Value Then Exit Do
Loop
End Function
------------------------
Public Function gADOGetRecordset_RO(szSP As String, Optional bolReturnError As Boolean = False) As ADODB.Recordset
Dim objRecordSet As New ADODB.Recordset
Dim intCount As Integer
Dim bErrorRaised As Boolean
Dim nErrNumber As Long
Dim szErrDesc As String
On Error GoTo HandleError:
With objRecordSet
.CacheSize = 500
.ActiveConnection = gudProfile.adoConnection
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Source = szSP
.Open
Exit Function