Wrox Programmer Forums
|
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
 
Old July 17th, 2003, 02:27 PM
Authorized User
 
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?

 
Old July 17th, 2003, 02:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old July 17th, 2003, 03:17 PM
Authorized User
 
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

how would i open the connection where it would allow backward movement?

 
Old July 17th, 2003, 03:21 PM
Authorized User
 
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


 
Old July 17th, 2003, 03:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old July 17th, 2003, 04:09 PM
Authorized User
 
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you. anyone else?

 
Old July 18th, 2003, 01:51 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old July 22nd, 2003, 03:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
skipping records while looping stealthdevil Access VBA 3 October 26th, 2006 10:22 AM
Looping through all records in excel? dhl365 Pro VB 6 1 July 26th, 2005 03:39 PM
A Cursor counting records chubnut SQL Server 2000 12 July 8th, 2004 01:58 PM
Looping through subform records V Access VBA 8 April 20th, 2004 08:10 AM
looping through return records in sproc jtyson SQL Server ASP 5 July 14th, 2003 10:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.