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!

moveNext, movePrev not working

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Please help me resolve this, gurus.
I have a page called view_recs.asp.
It pulls records from the database and displays the records to the screen.
Then I have this code called moveNext.asp.
When records are pulled from the database, view_recs.asp calls moveNext to pull next row of data from the database.
It it will keep calling moveNext until all records are pulled from the database or until it decides to call movePrev to go back.
my code moveNext is not working, neither is movePrev.
Here is the syntax for moveNext and please tell me what is wrong.
thx

<%@ Language=VBScript%>
<%Option Explicit%>
<%Response.buffer=true%>

<%
dim connectionToDatabase,rs
Set connectionToDatabase=Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rs=Server.CreateObject(&quot;ADODB.Recordset&quot;)
connectionToDatabase.Open &quot;DSN=aTrac;
rs.Open &quot;SELECT * FROM tblcar&quot;,connectionToDatabase,3,3
if rs.EOF Then
rs.moveFirst
end if

if rs.BOF then
rs.MoveLast
End If

rs.MoveNext
Response.Redirect &quot;view_records.asp&quot;

connectionToDatabase.Close
' Set connectionToDatabase=Nothing
%>
 
The issue here is that if you have no records returned than the recordset will be both EOF and BOF and thus unable to movefirst or move last. If there are any records in the recordset than it will not be either BOF or EOF. In my expperience I have never seen a recordset returned with the pointer pointing to either EOF or BOF if there was a valid record in the set (this is only ASP, I have seen it in several other languages).
Also, by response.redirecting you are loding all data in storage for the current script and starting a new script from scratch (in this case view_records.asp). You may wish to just include the view_records script in this location in order to keep your recordset intact.
-Tarwn ------------ My Little Dictionary ---------
Extreme Programming - (1)Trying to code before my second cup of coffee. (2) While(1){ Ctrl+C; Ctrl+V; }
FAQ - Web-ese for &quot;Forget Asking Questions, I am to busy&quot; :p
 
No guru here, but if the code above is supposed to be getting called continually till it reaches the end of the database, well each time its called it creates a new recordset so it will never get any further than the first record!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top