 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 17th, 2003, 02:27 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
where is cursor after looping through records?
if i loop through a recordset using "do while not rs.eof" and my ending code is rs.movenext
loop
and then a while later in my code i repeat this same operation (code), where is the cursor in ralation to the recordset once i start this next block of code? is it at the end of the recordset, beginning, or somewhere in between?
|
|

July 17th, 2003, 02:30 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
when it hits rs.EOF, it stays there unless you move it using a rs.moveprevious, or rs.movefirst. These 2 options will only work if the recordset was opened in a way that allows moving back up the recordset.
Chris
|
|

July 17th, 2003, 03:17 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
how would i open the connection where it would allow backward movement?
|
|

July 17th, 2003, 03:21 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
this is how i'm opening may database connection...
option explicit
dim conn, rs, sql, dbPath
set conn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.RecordSet")
dbPath = Server.MapPath("asp/davidData.mdb")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" & dbPath
|
|

July 17th, 2003, 03:31 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I have never needed to go backward on an ASP page at my current job, so I am not exactly sure right off without searching for sample code. Does anyone else know?
There are other parameters when opening the rs. One is locktype which I believe is the one that controls this. I cannot remember the exact syntax and all my code I used it with is at my other job.
Chris
|
|

July 17th, 2003, 04:09 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thank you. anyone else?
|
|

July 18th, 2003, 01:51 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
If you want a recordset that supports .MoveFirst, try this:
Code:
rsRecordset.CursorLocation = adUseClient
rsRecordset.Open cmdCommand, , adOpenDynamic, adLockBatchOptimistic
This creates a client side cursor that will support backwards navigation in the Recordset.
For more info, check out:
http://www.adopenstatic.com/faq/800a...dsetOpenSyntax
HtH
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

July 22nd, 2003, 03:55 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Alternatively you could just get the recordset into an array using GetRows() then you can access it as many times as you like without having to use expensive cursors.
|
|
 |