Solved

ASP GetRows Error

Posted on 2013-11-27
19
424 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
 
LVL 32

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 32

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 32

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 32

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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 32

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 32

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 32

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now