Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getrows (asp 3.0 not .net) 2

Status
Not open for further replies.

Krickles

Technical User
Apr 13, 2002
92
US
I'm using the getrows method to return an array. No matter which table I point to, I only load half of the records (regardless of total record count). Code chunk below:
Code:
Set objRec = server.CreateObject("ADODB.Recordset")
objRec.Open "select * from division_lu", objConn

Dim arrResults, intLastCol, intLastRow, intCol, intRow

arrResults = objRec.GetRows

intLastCol = UBound(arrResults)
intLastRow = UBound(arrResults)

For intRow = 0 to intLastCol
  For intCol = 0 to intLastRow
    Response.Write arrResults(intCol, intRow) & "   "
  Next
    Response.Write (&quot;<BR>&quot;)
Next
Please advise. Regards, Krickles
 
In your example you're not being specific about which dimension you're looking for in your
Code:
Ubound()
statements. To do so use:
Code:
intLastCol = UBound(arrResults,1)
intLastRow = UBound(arrResults,2)
 
When I do as recommended, the following error occurs (tried on two different tables):

Subscript out of range: 'X'

where X = number of columns in the respective table.

 
Genimuse is correct but the direction on using the count may be wrong plus the subscript coding.
just a little more to the accurate count with the ubound to avoid the subscript.
check the example listed here

should get your table looking spiffy, with all the records :)

____________________________________________________
$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;

onpnt2.gif
 
As onpnt hinted at, the lines below are wrong:

For intRow = 0 to intLastCol
For intCol = 0 to intLastRow

Read it slowly (or perhaps read it out loud) and I think you'll notice the problem.

codestorm
Newbie Life Member.
Fire bad. Tree pretty. - Buffy
<insert witticism here>
 
Yep. My fix was correct, but I missed the second problem. Good catch, codestorm.

(I use GetRows all the time and so knew my post was correct, so I was really confused when it didn't run!)
 
Thanks onpnt for the link and thanks codestorm for noting the row=col mistake. It is working now. Regards, Krickles
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top