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

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?

LVL 1
kevinkcwAsked:
Who is Participating?
 
ap_sajithCommented:
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
 
vijay7248Commented:
Hi,
May be this could solve ur prob..
Give
      rsShooters.Movefirst
after your  rsShooters.Getrows line

-Vijay
0
 
kevinkcwAuthor Commented:
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
vijay7248Commented:
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
 
vijay7248Commented:
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
 
kevinkcwAuthor Commented:

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
 
ap_sajithCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.