Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 adGetRowsRest and another question

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
cripto9t Posted - 11 March 2011 : 14:21:31
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
7   L A T E S T    R E P L I E S    (Newest First)
Doug G Posted - 13 March 2011 : 19:31:05
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.
HuwR Posted - 13 March 2011 : 02:47:10
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.
Doug G Posted - 12 March 2011 : 20:16:49
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.
cripto9t Posted - 12 March 2011 : 07:12:31
oh man, I should be setting the row count to "", not the array.
Thanks Huw
HuwR Posted - 12 March 2011 : 05:19:48
you have to check for an array because that is what you are being given, getRows returns an array
cripto9t Posted - 11 March 2011 : 15:26:48
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.
HuwR Posted - 11 March 2011 : 14:51:05
do you have an include file that defines what adGetRowsRest is supposed to be ?

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000 Version 3.4.07