Solved

ASP GetRows Error

Posted on 2013-11-27
19
428 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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