Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 adGetRowsRest and another question
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cripto9t
Average Member

USA
881 Posts

Posted - 11 March 2011 :  14:21:31  Show Profile  Reply with Quote
I get an error when I use GetRows(adGetRowsRest). I have to use GetRows(-1)
ADODB.Recordset (0x800A0C93)
Operation is not allowed in this context.
/my_cards/set.asp, line 208


Also, I have to check for an array if the query comes back with rows, else I get a type mismatch error.
What could cause this?

Sub GetCards()
    dim strSql, rs, allSRData, SetRows

    strSql = "SELECT SR_CARDS FROM " & strTablePrefix & "SET_ROW " & _
             "WHERE SET_ID = " & SetID & " AND SR_CARDS > 0 AND SR_ROW_TYPE = 4"

    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.open strSql, my_Conn

    if rs.EOF or rs.BOF then
        allSRData = ""
    else
        allSRData = rs.GetRows(-1)    'adGetRowsRest draws an error 
        SetRows = uBound(allSRData,2)
    end if

    rs.close
    set rs = nothing

    if not isArray(allSRData) then  'if allSRData = "" then -draws an error 
        SetCards = 0
        SetUniqueCards = 0
    else
        SetCards = SetRows + 1
    end if
End Sub

    _-/Cripto9t\-_

HuwR
Forum Admin

United Kingdom
20608 Posts

Posted - 11 March 2011 :  14:51:05  Show Profile  Visit HuwR's Homepage  Reply with Quote
do you have an include file that defines what adGetRowsRest is supposed to be ?

MVC .net dev/test site | Snitz .NET Core running on Raspberry Pi

Go to Top of Page

cripto9t
Average Member

USA
881 Posts

Posted - 11 March 2011 :  15:26:48  Show Profile  Reply with Quote
Nope it's been awhile. I just found that out in my search.
I still have to check for an array. I thought maybe they were connected.

    _-/Cripto9t\-_
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20608 Posts

Posted - 12 March 2011 :  05:19:48  Show Profile  Visit HuwR's Homepage  Reply with Quote
you have to check for an array because that is what you are being given, getRows returns an array

MVC .net dev/test site | Snitz .NET Core running on Raspberry Pi

Go to Top of Page

cripto9t
Average Member

USA
881 Posts

Posted - 12 March 2011 :  07:12:31  Show Profile  Reply with Quote
oh man, I should be setting the row count to "", not the array.
Thanks Huw

    _-/Cripto9t\-_
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 12 March 2011 :  20:16:49  Show Profile  Reply with Quote
I used to use getrows() a lot years back, unless something has changed getrows() didn't return an array if you called it on an empty recordset, it used to return -1 or some other single value.

I always tested the return of getrows() with IsArray, and to make the rest of my code work right I converted the return value to an array so I could just pass along getrows() output to downstream code without having to test later on in the code.

======
Doug G
======
Computer history and help at www.dougscode.com
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20608 Posts

Posted - 13 March 2011 :  02:47:10  Show Profile  Visit HuwR's Homepage  Reply with Quote
can't find anything that says it returns -1, the MS docs just say it returns an array, good practice would be to check if the recordset was empty before calling getRows. IIRC calling GetRows on an empty recordset errors rather than returning a value.

MVC .net dev/test site | Snitz .NET Core running on Raspberry Pi

Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 13 March 2011 :  19:31:05  Show Profile  Reply with Quote
I know the docs say getrows() will return an array, but in extensive code I used a few years back I can say that getrows() did not always return an array. Maybe I can find some of that code and the notes I kept back then.

======
Doug G
======
Computer history and help at www.dougscode.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000 Version 3.4.07