Solved

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

Posted on 2003-11-26
7
1,081 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Expert Comment

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

-Vijay
0
 
LVL 1

Author Comment

by:kevinkcw
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 21

Accepted Solution

by:
ap_sajith earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility

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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

16 Experts available now in Live!

Get 1:1 Help Now