Solved

ASP GetRows Error

Posted on 2013-11-27
19
431 Views
Last Modified: 2013-11-27
I am getting this error: Bookmark is invalid.

On this line:         IndRslts = rs.GetRows(iNumRcds, iFirstRcd)

It works fine if I take the parameters out.  iNumRcds = 75 and iFirstRcd = 1 in this case.

Thanks!
0
Comment
Question by:Bob Schneider
  • 9
  • 7
  • 2
  • +1
19 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 39680544
Are there 75 records in the recordset?
0
 

Author Comment

by:Bob Schneider
ID: 39680546
There are 81
0
 
LVL 25

Assisted Solution

by:Lee Savidge
Lee Savidge earned 63 total points
ID: 39680560
Hmm, actually it shouldn't matter eitehr way. If there are less then it will return all of them.

iFirstRcd should be a string and not an integer.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 375 total points
ID: 39680569
I'm guessing it has to do with the easy you're handling the cursor when you open the record set. Can you post your code for that?
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39680574
Easy = way

Damn auto correct :-)
0
 

Author Comment

by:Bob Schneider
ID: 39680586
            sql = "SELECT pr.Bib, p.FirstName, p.LastName, p.Gender, pr.Age, ir.ChipTime, ir.FnlTime, ir.ChipStart, p.City, p.St "
            sql = sql & "FROM Participant  p INNER JOIN IndResults ir ON p.ParticipantID = ir.ParticipantID "
            sql = sql & "INNER JOIN PartRace pr ON pr.ParticipantID = p.ParticipantID "
            sql = sql & "INNER JOIN RaceData rd ON rd.RaceID = pr.RaceID AND rd.RaceID = ir.RaceID "
            sql = sql & "WHERE ir.RaceID = " & lRaceID & " AND ir.FnlTime IS NOT NULL ORDER BY ir.ChipTime"
        Else
            sql = "SELECT pr.Bib, p.FirstName, p.LastName, p.Gender, pr.Age, ir.ChipTime, ir.FnlTime, ir.ChipStart, p.City, p.St "
            sql = sql & "FROM Participant  p INNER JOIN IndResults ir ON p.ParticipantID = ir.ParticipantID "
            sql = sql & "INNER JOIN PartRace pr ON pr.ParticipantID = p.ParticipantID "
            sql = sql & "INNER JOIN RaceData rd ON rd.RaceID = pr.RaceID AND rd.RaceID = ir.RaceID "
            sql = sql & "WHERE ir.RaceID = " & lRaceID & " AND p.Gender = '" & sGender & "' AND ir.FnlTime IS NOT NULL ORDER BY ir.ChipTime"
        End If

        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.Open sql, conn, 1, 2
        IndRslts = rs.GetRows(iNumRcds, iFirstRcd)
        rs.Close
        Set rs = Nothing

Open in new window

0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 375 total points
ID: 39680863
just as a test and before we dive too far into cursors, can you try changing:

rs.Open sql, conn, 1, 2

to

set rs = conn.Execute( sql )
0
 

Author Comment

by:Bob Schneider
ID: 39680936
I can do that but the problem with that is if there are no records it will throw an error, correct?
0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 375 total points
ID: 39680948
if that is a concern, then you could always check before doing getRows():

if not rs.BOF and not rs.EOF then
    IndRslts = rs.GetRows(iNumRcds, iFirstRcd)
end if
0
 

Author Comment

by:Bob Schneider
ID: 39680953
Here's what I got: Current Recordset does not support bookmarks. This may be a limitation of the provider or of the selected cursortype.
0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 375 total points
ID: 39680987
ok, I thought that may happen, but just wanted to make sure :)

can you try the following code?

rs.CursorLocation =  adUseServer
rs.Open sql, conn, adOpenDynamic, adLockReadOnly, adCmdText

you'll need adodb.inc to get all of the CONSTANTS values, which you can download from

http://www.4guysfromrolla.com/webtech/code/adovbs.txt

rename it to a ".inc" extension and include it before the code
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 62 total points
ID: 39681329
I am getting this error: Bookmark is invalid.
Here is the reason you are getting the error:
If the Recordset object supports bookmarks, you can specify at which record the GetRows method should begin retrieving data by passing the value of that record's Bookmark property in the Start argument.

Both:
rs.Open sql, conn, 1, 2
and
set rs = conn.Execute( sql )
Do not support book marks.  You can confirm this by checking the value for rs.Supports(adBookmark)
0
 

Author Comment

by:Bob Schneider
ID: 39681346
Where do I put that file and how do I reference it in my code?
0
 

Author Comment

by:Bob Schneider
ID: 39681353
Ok so how can I make this work?  I really want to be able to tell the db where to start and how many  records to et.
0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 375 total points
ID: 39681359
i assume you're looping through the array, correct? why not just use iFirstRcd as the starting point in your loop?
0
 

Author Comment

by:Bob Schneider
ID: 39681365
I can do that but I am trying to minimize the resource drain and I figured I could just tell it where to start and how many records to get and that would be quicker.  No?
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 375 total points
ID: 39681370
then that should be done directly in your sql query. you should only return the data that you're going to need for the page, and no more. how many records get returned?
0
 

Author Comment

by:Bob Schneider
ID: 39681470
Got it.  I works if I just tell it how many records to get.  I built the start point into the query.
0
 

Author Closing Comment

by:Bob Schneider
ID: 39681476
Great discussion...very informative.
0

Featured Post

Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Recursion schedule 13 34
MS SQL and inserting dates into tables using stored procedures 6 36
SQL QUERY 3 33
Using this function 4 38
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question