Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function goes into infinite loop

Status
Not open for further replies.

developer155

Programmer
Jan 21, 2004
512
US
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
 
Hi:

In your Pause sub, I would like to suggest one minor modification.

Change
Code:
If GetTickCount = PreTick + Value Then Exit Do
to
Code:
If GetTickCount >= PreTick + Value Then Exit Do
to remove the possible endless loop should GetTickCount skip over the value of PreTick + Value.

Cassie

Cassie
PIII-500Mhz-128MB
Win98SE-VB6SP5
 
Hi:

In your gADOGetRecordset_RO function, where do you set gADOGetRecordset_RO to the objRecordSet?

Also, it appears that you are missing a "End With" in the gADOGetRecordset_RO function.


Cassie
PIII-500Mhz-128MB
Win98SE-VB6SP5
 
your code is incomplete i suggest u should post the complete code so that we could help u better...
 
Do a control-break and see where it stops in the code when you have the infinite loop.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top