Solved

GetRows Method and "error '800a0c93' Operation is not allowed in this context."

Posted on 2003-11-26
7
1,092 Views
Last Modified: 2007-12-19
Having a devil of a time figuring this one out, maybe because it's 3:30 in the a.m., but can anyone help me figure out why I get this error?

-------------------

ADODB.Recordset error '800a0c93'

Operation is not allowed in this context.

/ncc-lab/shooters/gallery.asp, line 162

-------------------

The line in question is:

-------------------
      aryCons=rsShooters.GetRows(PageSize, adBookmarkCurrent)
-------------------

Apparently, the reason it didn't error out on the earlier line similar to this one is that the IF statement is evaluating to false with my test data.

Full code snippet:

-------------------


Dim CurrentPage, I, aryPros, intProsPages, aryCons, intConsPages, intMaxPages
I = 5 ' the page size. Change to have more or less records per page displayed.
If IsEmpty(Request.QueryString("PageNumber")) Then
      CurrentPage=1
Else
      CurrentPage=CInt(Request.QueryString("PageNumber"))
End If

' filter the page for userProfessional state
rsShooters.Filter="userProfessional=" & true

if not rsShooters.EOF then
      ' set the page size for the rs, so that AbsolutePage knows
      ' what factor to go by and locate the current page.
      rsShooters.PageSize=I
      
      ' move the cursor to the first record of the page we want.
      rsShooters.AbsolutePage=CurrentPage
      
      ' if this didn't move the cursor off the end of the set
      ' get the data from the subset into an array
       aryPros=rsShooters.GetRows(PageSize, adBookmarkCurrent)
      
      ' before we get rid of this subset, count the pages and save it for later
      intProsPages=rsShooters.PageCount
      
      ' set the filter back to nothing
      rsShooters.Filter=adFilterNone


end if

' filter the set now for the amatures
rsShooters.Filter="userProfessional=" & false

if not rsShooters.EOF then
      ' set the page size again, for fun
      rsShooters.PageSize=I
      
      ' as before, move the cursor
      rsShooters.AbsolutePage=CurrentPage

      ' if this didn't move the cursor off the end of the set
      ' get the data from the subset into an array
      aryCons=rsShooters.GetRows(PageSize, adBookmarkCurrent)
      
      ' before we get rid of this subset, count the pages and save it for later
      intConsPages=rsShooters.PageCount
      
      ' set the filter back to nothing
      rsShooters.Filter=adFilterNone
end if

' compare the two numbers of pages and set intMaxPages to that value.
if intConsPages>intProsPages then
      intMaxPages=intConsPages
else
      intMaxPages=intProsPages
end if

----------------------


I know it's ugly, but can you spot where I go wrong?

0
Comment
Question by:kevinkcw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Expert Comment

by:vijay7248
ID: 9823269
Hi,
May be this could solve ur prob..
Give
      rsShooters.Movefirst
after your  rsShooters.Getrows line

-Vijay
0
 
LVL 1

Author Comment

by:kevinkcw
ID: 9823327
Nope. I thought that too, at first. But I figured it out I think. Really was a 3 a.m. mistake. PageSize makes no sense in the context, PageSize is null, because it's not a variable. The variable I was using for PageSize is, actually, I. Plus, for whatever reason adBookmarkCurrent wasn't playing nice. Since I am working with the beginning of the subset anyway, this wasn't really necessary. But I'll give the points to whomever can tell me why adBookmarkCurrent was giving me an error (different one then is listed above.)
0
 
LVL 3

Expert Comment

by:vijay7248
ID: 9823395
Oh..I forgot to notice the Pagesize var..

adBookmarkCurrent or 0      - Points at the current record.
But in your case there is no current record at the beginning.
So try give rsShooters.Movefirst ......before the getrows

If still there is an error, replace adBookmarkCurrent with adBookmarkFirst or 1 , of course after giveing rsShooters.movefirst

adBookmarkFirst - points at the first record

Hope this helps..

-Vijay
0
Independent Software Vendors: 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 21

Accepted Solution

by:
ap_sajith earned 125 total points
ID: 9823402
Have you included the adovbs.inc file?

If not you will have to use numeric constants instead...

BookmarkEnum Values

Constant                    Value           Description
adBookmarkCurrent     0                Starts at the current record
adBookmarkFirst          1                Starts at the first record
adBookmarkLast          2                Starts at the last record


For more info on recordset paging using getRows method, see http://www.devhome.org/asp/

Cheers!!
0
 
LVL 3

Expert Comment

by:vijay7248
ID: 9823496
I think the error might be what ap_sajith has pointed out..
Since removing adBookmarkCurrent has solved ur prob it means that you have not included adovbs.inc file..
Instead try using 0 as ap_sajith has pointed..
0
 
LVL 1

Author Comment

by:kevinkcw
ID: 9823652

I have the ADO enumerated constants with....

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Type Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->


I will try using both the BookmarkEnum Values and moving the cursor to see if any of these answers work.

0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 10243545
Hi,
Any Updates?. Do you need any further assistance with this?. Please close this question if no further assistance is needed.
If you need help closing this question, please refer to http://oldlook.experts-exchange.com/help/closing.jsp on how to close a question.

Cheers!!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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