Recordset Move Next

O

Otuatail

I have a recordset that I can move next put not move last. Is ther
a way of connecting to the database (Access) to get around this please.


Set connection = Server.CreateObject("ADODB.Connection")
Set rsTeams = Server.CreateObject("ADODB.Recordset")
dsn = "DSN=Football"
connection.Open dsn
Access = Request("Access")
User = Request("User")
sqlTeams = "SELECT * from Teams"
rsTeams.Open sqlTeams, connection
rsTeams.MoveLast
Response.Write rsTeams("Name")


Paul
 
W

William Tasso

Otuatail said:
I have a recordset that I can move next put not move last.

Why not? What error do you get?
Is ther
a way of connecting to the database (Access) to get around this
please.

Do until hell.temp = water.freeze
rs.movenext
loop

don't forget to trap the error
 
C

Clive Moss

Otuatail said:
I have a recordset that I can move next put not move last. Is ther
a way of connecting to the database (Access) to get around this please.


Set connection = Server.CreateObject("ADODB.Connection")
Set rsTeams = Server.CreateObject("ADODB.Recordset")
dsn = "DSN=Football"
connection.Open dsn
Access = Request("Access")
User = Request("User")
sqlTeams = "SELECT * from Teams"
rsTeams.Open sqlTeams, connection
rsTeams.MoveLast
Response.Write rsTeams("Name")


Paul

I'm Not an expert on this but why not MoveNext until EOF:

rsTeams.Open sqlTeams
While Not rsTeams.EOF
rsTeams.MoveNext
Wend
Response.Write rsTeams("Name")

Clive
 
B

Beauregard T. Shagnasty

Quoth the raven named Otuatail:
I have a recordset that I can move next put not move last. Is ther
a way of connecting to the database (Access) to get around this please.


Set connection = Server.CreateObject("ADODB.Connection")
Set rsTeams = Server.CreateObject("ADODB.Recordset")
dsn = "DSN=Football"
connection.Open dsn
Access = Request("Access")
User = Request("User")
sqlTeams = "SELECT * from Teams"
rsTeams.Open sqlTeams, connection
rsTeams.MoveLast
Response.Write rsTeams("Name")

Is part of this query missing in your post? What is the Access and
User for?

sqlTeams = "SELECT * from Teams WHERE user = <% =User%> ORDER BY name
DESCENDING" [if I have the syntax correct - it's been awhile]

With DESCENDING the top record is already the "last" one. No need to
MoveLast.
 
A

Augustus

Otuatail said:
I have a recordset that I can move next put not move last. Is ther
a way of connecting to the database (Access) to get around this please.


Set connection = Server.CreateObject("ADODB.Connection")
Set rsTeams = Server.CreateObject("ADODB.Recordset")
dsn = "DSN=Football"
connection.Open dsn
Access = Request("Access")
User = Request("User")
sqlTeams = "SELECT * from Teams"
rsTeams.Open sqlTeams, connection
rsTeams.MoveLast
Response.Write rsTeams("Name")

Its hard to explain all this without going into a lengthy explanation, so
you might want to check out Google for information on the recordset object
and in particular look up "cursors" and "pointers"

But for the brief explanation:

In order for ASP to go through your database it uses a "cursor" to tell it
which record it is pointing at.

When you open a database as you did in the example above, you went for the
quick, fast and easy cursor. This cursor has only 2 movements: next
(movenext) and back to the start (movefirst).

To use commands like "moveprevious" or "movelast" you need to specify in
your recordset object that you want to use a different cursor

This site will explain abit more about cursors and which ones to use and
what they can each do:

http://www.scit.wlv.ac.uk/appdocs/chili-asp/html/ado_recordset_object_cursortype_property.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top