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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

objRecordset.EOF

Status
Not open for further replies.

damann

Technical User
Jul 19, 2000
114
US
objRecordset_query = "some query"
Set objRecordset = Server.CreateObject("ADODB.Recordset")
objRecordset.ActiveConnection = dbConn
objRecordset.CursorType = 3
objRecordset.Open objRecordset_query

Do Until objRecordset.EOF
If (StatChk(var1, var2)) Then
%>
Out comes some HTML...
<%
Exit Do
Elseif (StatChk(var1, var2)) Then
%>
Out comes some HTML...
<%
Exit Do
Elseif (objRecordset.EOF = True) Then
%>
Out comes some HTML...
<%

Exit Do
End If
objRecordset.MoveNext
Loop


Ok, everything above seem to work except he stuff in red. Why wont this chunk of code work? Why does Elseif (objRecordset.EOF = True) Then seem to like not exist? Please help, this is driving me insane...


Damann
 
You need to restructure your code a bit... if your recordset is EOF, it will not enter the loop.

Try something like this:

if objRecordset.EOF then
'write EOF html here
else
While NOT objRecordset.EOF
'perform checks and write other html here


objRecordset.MoveNext
WEND
end if
 
Always check first for EOF before you compare with any value. There may be no record at all or you may encounter eof in the middle.

if objRecordSet.eof() then

html code goes here

elseif ....
 
That didn't work either... Can .EOF and .BOF be true at the same time? I really can't understand this...



Damann

 
I've done a check before ll the above code to check if there's anything in te recordset. If there is That's when the above code starts.

It does the two first checks properly:
If (StatChk(var1, var2) = red) Then
%>
Out comes some HTML...
<%
Exit Do
Elseif (StatChk(var1, var2) = yellow) Then
%>
Out comes some HTML...
<%
Exit Do


I forgot the yellow and red, now there are two other values that StatChk can return and they are green and N/A. Red takes precedent over yellow and yellow takes precedent over everything else. So I want it to exit that loop if it's red, if not exit if it's yellow. This is the part that works. If it's not red or yellow, I want it to loop all the way to the EOF and if it's at the EOF and it's still not red or yellow, I want it to just print out what it is, which'll be green or N/A. This is the section that doesn't work, for some strange reason, it's not detecting if it's the EOF. So I'm thinking since there's probably only one row of data in the recorset BOF is true and not EOF. Can this be the case?


Damann
 
'ElseIf' should be 'Else If' Tony
reddot.gif WIDTH=400 HEIGHT=2 VSPACE=3

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top