[thelist] Please help with asp getrows

Max Schwanekamp lists at neptunewebworks.com
Thu Jul 20 12:34:48 CDT 2006

> -----Original Message-----
> From: Brian Delaney 
> This code is only giving me the first 4 records from the sql 
> record set.
>   Set rsServiceList1 = Server.CreateObject("ADODB.Recordset")
>   strSQL1 = "Select * from Services where catagoryid = " & 
> "'" & mid(rsCatagoryList("ID"),2,36) & "'" & " order by name "
>   rsServiceList1.Open strSQL1, ResourceCatalogDBConn 
>   DBServicesArray1 = rsServiceList1.GetRows
>   rsServiceList1 can contain 1-25 records.   
>   Any help will be appreciated.

So, does that mean when you run this query in Query Analyzer (or similar
tool), you get 25 records with the same query?  All that GetRows does is put
a whole recordset into a 2-dimensional array.  It has been a while since
I've played in old ASP/VB, but IIRC the idea with GetRows() is, you run your
query, pull all the data into an array at once, close the connection, then
quickly iterate over the array rather than slowly over the recordset object.
(E.g. [0])  Right?  So are you saying that when you run this query using
GetRows, you get different results than running it in Query Analyzer?  Some
additional information about what you did and what you expected would be
helpful in getting a more on-target response[1].

That said, you might check that you're using the right variable for
determining the number of rows in the array returned by GetRows.  E.g., you
would use UBound(DBServicesArray1,2).  Back in the day, I recall often
accidentally forgetting to specify which dimension I wanted, so I would end
up thinking I had e.g. UBound(DBServicesArray1) rows, which is actually the
number of columns.

[0] http://www.asp101.com/samples/viewasp.asp?file=db%5Fgetrows%2Easp
[1] http://www.catb.org/~esr/faqs/smart-questions.html

Max Schwanekamp

More information about the thelist mailing list