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

Quick Question about BOF

Status
Not open for further replies.

krymzon

Programmer
Feb 22, 2005
38
0
0
CA
just wanted to test out some theory code before i dive into my next application, and i've found that the simplest method for m situation would be to figure out if i'm currently on the first record without having to execute a query and compare.

rec.MoveFirst
if rec.BOF then
response.write("blarg")
end if

so, i tried out a peice of quick little code like this (don't worry, i have all the proper connections and stuff), and it returned nothing. beignthe newbie i am to asp still, i was just wondering if this is even a feasable coding method.

--there are 10 types of people in this world. those who know binary, and those who don't.--
 
Code:
>>The BOF property returns True (-1) if the current record position is before the first record in the Recordset, otherwise it returns False (0).

>>The EOF property returns True (-1) if the current record position is after the last record in the Recordset, otherwise it returns False (0). 

>>The BOF and EOF properties are set to True if you open an empty Recordset. RecordCount property is zero. 

>>If a Recordset holds at least one record, the first record is the current and the BOF and EOF properties are False.

-DNG
 
great, thanks. thought that since i was on the first record BOF would be false. so, i'll just do a little manual first record check. nothing is as easy as i want it to be i guess...lol

--there are 10 types of people in this world. those who know binary, and those who don't.--
 
As long as you have already checked that the recordset is not empty (check EOF AND BOF) then simply doing a .MoveFirst will be sufficient whenever you want to move the cursor back to the start of the recordset.

The cursor will start at the beginning of the recordset by default so no need to do it the first time you go through.
Code:
If NOT rs.EOF AND NOT rs.BOF Then
 ' use your recordset
End If

Tony

Spirax-Sarco - steam traps control valves heat exchangers
Sun Villa - Luxury Florida accommodation
 
Oh, and remember that MoveFirst won't work if your recordset has the default ForwardOnly cursor.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top