Random record from objRS - why is EOF or BOF True?
Hi,
I'm after creating a scrolling text box (marquee) to display random quotes from our customers. I've created a db table to hold the quotes - at the moment I've just added 3 records to the table.
I'm using code to select a record at random, and display the quote along with a link to the Full Story - but intermittently I'm getting an error as follows:
ADODB.Field error '80020009'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
Here's the code I'm using...
<marquee height="100" vspace="15" scrollamount="1" direction="up" width="100%">
Set objRS = Server.CreateObject("ADODB.RecordSet")
strSQL1 = "SELECT * FROM tblQuotes"
objRS.CursorLocation = adUseClient
objRS.Open strSQL1, strConnect
While True
Randomize
intRandom = Int(objRS.RecordCount * Rnd)
objRS.Move intRandom
Response.Write(objRS.Fields("memQuote"))
Response.Write(" <br /> <a href=" & objRS.Fields("txtLink") & " class='BodyLink'>Read the Full Story...</a>")
Wend
objRS.Close
%>
</marquee>
I've put in a Response.Write line to display the intRandom figure, and it's always between 0 and 2. It'll display the info correctly for a record, then next time it tries to display that same record, it gives the error!
Please help!
J.
|