Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


subscript out of range 'groups'

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,28693
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> subscript out of range 'groups'
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 subscript out of range 'groups' - 12/6/2005 1:44:36 AM   
  csamuels


Posts: 42
Score: 0
Joined: 9/26/2005
Status: offline
im getting this error


Microsoft VBScript runtime error '800a0009'
Subscript out of range: 'groups'
/tasks/irsecurity.asp, line 58


<%
dim tries, conn, rs, connresult, groups
function openconn ' open a connection to access db'
dim tries
set conn = CreateObject("ADODB.Connection") 'prep connection'
set rs = CreateObject("ADODB.Recordset") ' prep recordset'
tries = 0 ' clear tries counter'
do 'try to open connection to the db
   conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=imagergt;UID=sa;PWD=xxxxx;DATABASE=ImgRight"
   tries = tries + 1
   if (err.number <> 0) then 'if errored, close this connection
     conn.close
   end if
Loop While (Err.Number<>0) And tries < 10 'if errored, try again. MAX TRIES = 10
'Check Connection
If (Err.Number<>0) Then
   response.write err.desc
   openconn = 1
   exit function
else
   openconn = 0
End IF
end function
sub closeconn ' close the connection to the db
rs.close
set rs = nothing
conn.close
set conn = nothing
end sub
sub main
connresult = openconn
if connresult then
   exit sub
end if

query = "Select userid from irsysusers where isgroup = 1"
rs.open query, conn
if err.number<>0 then
   response.write err.description
   exit sub
else
   if rs.eof then
     response.write "Query returned nothing<BR>" & query
     exit sub
   else
     groups = rs.getrows
     'for each i in groups
     '  response.write groups(0,i) & "<BR>"
     'next
    
     for i = LBound(groups) to UBound(groups)
       response.write groups(i) & "<BR>" 'ERROR HERE
     next
   end if
end if
closeconn
end sub
main
%>
 
 
Post #: 1
 
 RE: subscript out of range 'groups' - 12/6/2005 1:51:52 AM   
  csamuels


Posts: 42
Score: 0
Joined: 9/26/2005
Status: offline
  groups = rs.getrows
  'for each i in groups
  '  response.write groups(0,i) & "<BR>"
  'next
  rs.movefirst
  response.write rs.getstring & "<BR>"
  response.write LBound(groups) & " - " & UBound(groups) & "<BR>"
  for i = LBound(groups) to UBound(groups)
 response.write groups(0,i) & "<BR>"
  next


produces

-1 205 217 221 225 227 231 233 235 237 239 241 243 245 247 249 251 253 263 271 275 277 279 283 285 287 289 291 293 295 297 299 301 303 305 307 309 311 313 315 317 319 321 323 325 327 329 331 333 335 337 339 341 345 347 349 351 353 355 357 359 361 363 365 367 369 371 373 375 377 379 381 387 389 391 395 397 399 401 403 405 407 409 411 413 415 419 421 423 425 427 436 440 442 444 446 448 450 452 454 456 460 480 482 484 486 488 490 492 494 496 498 500 502 504 506 508 510 512 514 516 518 520 522 524 526 528 530 532 534 536 538 540 544 548 556 558 564 568 574 580 582 584 586 588 590 592 594 596 598 600 602 604 606 610 612 614 618 620 622 624 626 634 636 640 644 646 654 656 658 660 664 666 668 672
0 - 0
-1

(in reply to csamuels)
 
 
Post #: 2
 
 RE: subscript out of range 'groups' - 12/6/2005 3:19:37 AM   
  csamuels


Posts: 42
Score: 0
Joined: 9/26/2005
Status: offline
groups = rs.getrows
  rs.movefirst
  for each i in groups
response.write i & "<BR>"
  next


works now, thx close

(in reply to csamuels)
 
 
Post #: 3
 
 RE: subscript out of range 'groups' - 12/12/2005 11:33:16 AM   
  johnrswanton

 

Posts: 4
Score: 0
Joined: 11/16/2005
Status: offline
im not sure but i think you have to declare groups as an array

dim groups(100)

hope it helps
new to asp as well

(in reply to csamuels)
 
 
Post #: 4
 
 RE: subscript out of range 'groups' - 9/7/2006 8:05:59 PM   
  Tomislav

 

Posts: 1
Score: 0
Joined: 9/7/2006
Status: offline
Hi,

im getting this error

Microsoft VBScript runtime error '800a0009'
Subscript out of range: 'orderTotal'
/index.asp, line 318


--
From line 307



</tr>
                             </table> </td>
                         </tr>
                         <tr>
                           <td align="left" class="manjitekst">
                             <%

FOR x = 0 TO UBOUND( localCart, 2 )


IF localCart( CARTPID, x ) <> "" THEN
orderTotal=orderTotal + ( localCart( CARTPPRICE, x ) * localCart( CARTPQUANTITY, x ) )

chId=(localCart( CARTPID, x) )
chProduct=Server.HTMLEncode( localCart( CARTPNAME, x ) )
chPrice=localCart( CARTPPRICE, x )
chQuantity=localCart( CARTPQUANTITY, x )%>


                             <%=chProduct%>-<b><%=chPrice&" kn" %></b>(<%=chQuantity%> kom)<br>
                            <%
END IF
NEXT
%>



--




(in reply to johnrswanton)
 
 
Post #: 5
 
 RE: subscript out of range 'groups' - 9/8/2006 5:04:25 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Are you sure that localCart contains any data at all?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Tomislav)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> subscript out of range 'groups' Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts