adGetRowsRest and another question - نوشته شده در (1528 Views)
Average Member
cripto9t
مطلب: 881
881
I get an error when I use GetRows(adGetRowsRest). I have to use GetRows(-1)
Code:
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?
Code:
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\-_
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Forum Admin
HuwR
مطلب: 20611
20611
do you have an include file that defines what adGetRowsRest is supposed to be ?
نوشته شده در
Average Member
cripto9t
مطلب: 881
881
Nope smile 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\-_
نوشته شده در
Forum Admin
HuwR
مطلب: 20611
20611
you have to check for an array because that is what you are being given, getRows returns an array
نوشته شده در
Average Member
cripto9t
مطلب: 881
881
oh man, I should be setting the row count to "", not the array. Thanks Huw
    _-/Cripto9t\-_
نوشته شده در
Support Moderator
Doug G
مطلب: 6493
6493
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
نوشته شده در
Forum Admin
HuwR
مطلب: 20611
20611
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.
نوشته شده در
Support Moderator
Doug G
مطلب: 6493
6493
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
 
شما باید یک متن وارد کنید