View Full Version : can't get this... "Expected integer constant"
ShMiL
12-16-2005, 09:34 AM
dbConn
set rs = Server.CreateObject("ADODB.RecordSet")
sqlt = "SELECT [id],[orderID],[catTitle] FROM boardCategories ORDER BY [orderID]"
rs.Open sqlt,conn,3,1
if rs.eof then
rs.Close
Set rs = Nothing
else
RSa = rs.getrows()
rs.Close
Set rs = Nothing
Leng = cint(Ubound(RSa,2)
Dim rbArr(Leng,1)
for i=0 to Leng
rbArr(i,0) = RSa(2,i)
rbArr(i,1) = "?id="& RSa(0,i)
next
end if
dbClose
I get "Expected integer constant" for no reason. When I print it on the screen it shows an integer, and in order to be sure, I put wrapped it with the cint() function.
WTF?!
BarrMan
12-16-2005, 10:01 AM
cint(Ubound(RSa,2))
ShMiL
12-16-2005, 11:24 AM
cint(Ubound(RSa,2))
this typo is only here.
The original don't have it.
Roelf
12-16-2005, 11:40 AM
on what line do you get the error??
might want to check first if the RSa is indeed an array, before using the UBound function
If IsArray(RSa) Then
'do your handling
Else
'show error message
End If
BarrMan
12-16-2005, 01:10 PM
If IsNumeric(RSa) Then
Leng = CInt(UBound(RSa,1))
Else
'notify not numeric
End If
Roelf
12-16-2005, 01:25 PM
If IsNumeric(RSa) Then
Leng = CInt(UBound(RSa,1))
Else
'notify not numeric
End If
BarrMan, the getrows() function returns a 2-dimensional array, so you might want to explain why you check for isnumeric() and why you try to find the upper boundary of something you just tested to be numeric?
ShMiL
12-16-2005, 02:15 PM
RSa MUST be an array. (but to be sure, i tried isArray for checking)
The error points to the line that defines the array:
Dim rbArr(Leng,1)
----------^
Roelf
12-16-2005, 04:55 PM
i cannot see the reason for this error. Are you sure the var Leng holds a legal value?
TheShaner
12-16-2005, 05:06 PM
This will explain your error:
http://www.codefixer.com/tutorials/arrays.asp
Basically, when you declare an array for the first time, you cannot use a variable. You must use an actual integer or declare it first as a dynamic array.
So you would first do:
Dim rbArr()
Then you can do:
Redim rbArry(Leng,1)
-Shane
ShMiL
12-16-2005, 05:12 PM
leng equals 5 but isnumeric(leng) returns false.
What is this?
TheShaner
12-16-2005, 05:29 PM
Did you Dim Leng first? Also, did you try what I posted above?
-Shane
ShMiL
12-16-2005, 05:40 PM
Did you Dim Leng first? Also, did you try what I posted above?
-Shane
I tried what you say, it's working now.
Thanks.
(had no idea that i can't use vars there)
TheShaner
12-16-2005, 05:48 PM
Yeah, welcome to ASP and Arrays, lol.
-Shane
Roelf
12-18-2005, 12:00 PM
you mean, welcome to vbscript and arrays.
JScript will handle arrays like a breeze
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.