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)
 Problem Getting Records From Database
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

giambona
New Member

USA
84 Posts

Posted - 27 June 2001 :  12:29:04  Show Profile  Visit giambona's Homepage
I am getting records from an array in an ASP page and I am getting the following error:

quote:

Microsoft VBScript runtime error '800a0009'

Subscript out of range: '2'

/default.asp, line 441



Does anyone have any idea why? I have tried everything I can think of, but I'm a newbie so i don't know.

Here's my code:

quote:

alldata = rsTemp.GetRows
rsTemp.close
Set rsTemp = Nothing
conntemp.close
Set conntemp = Nothing

numcols = ubound(alldata, 1)

numrows = ubound(alldata, 2)

Response.Write numrows

strDate = FormatDateTime(Date, 1)

Response.Write "<p align=""center""><b><font face=""Arial"" color=""#f0c807"" size=""3""><u>" & strDate & "</u></font></b>"

For Counter = 0 To numcols

Response.Write Counter

strLink = alldata(3, Counter)

strTitle = alldata(1, Counter)

strPoster = alldata(4, Counter)

strDesc = alldata(2, Counter)

Response.Write "<p><b><a href=""" & strLink & """><font size=""2"" color=""#006699"" face=""Arial"">" & strTitle & "</font></a></b><br>"

Response.Write "<font face=""Arial"" size=""1"" color=""#000000"">(Posted by: <a href=""mailto:" & strPoster & """>" & strPoster & "</a>)</font><br>"

Response.Write "<font face=""Arial"" size=""2"" color=""#000000"">" & strDesc & "</font></p>"

Next



Thanks in advance for any help.

redbrad0
Advanced Member

USA
3725 Posts

Posted - 27 June 2001 :  12:37:36  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
try this....

for i=lbound(alldata) to ubound(alldata)
Response.Write alldata(i,0)
Response.Write alldata(i,1)
Response.Write alldata(i,2)
next

quote:

numcols = ubound(alldata, 1)
numrows = ubound(alldata, 2)
Response.Write numrows



something to keep in mind is that arrays start with 0, not 1

Brad
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 27 June 2001 :  16:26:27  Show Profile
Use for counter = 0 to numRows, not numCols.


======
Doug G
======
Go to Top of Page

giambona
New Member

USA
84 Posts

Posted - 27 June 2001 :  16:30:19  Show Profile  Visit giambona's Homepage
thanks to both of you

after i saw redbrad's post, i tried screwing around with it (i was a little bit confused) and figured it out

Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 27 June 2001 :  17:01:14  Show Profile
quote:
for i=lbound(alldata) to ubound(alldata)
Response.Write alldata(i,0)
Response.Write alldata(i,1)
Response.Write alldata(i,2)
next

This isn't correct for GetRows()

Assuming i is your row counter, the array is constructed as

alldata(0, i)
alldata(1, i)

where the 1st array level is the column number.


======
Doug G
======
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.35 seconds. Powered By: Snitz Forums 2000 Version 3.4.07