shank
Thu Mar 13 14:05:23 CDT 2008
>>Response.Write(arrResultSet(1,iCounter) & "")<<
That was the problem,
Should have been...
Response.Write(arrResultSet(0,iCounter) & "")
thanks!
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:%23FhmvlThIHA.4844@TK2MSFTNGP06.phx.gbl...
> shank wrote:
>> Trying to learn and use GetRows.
>> I'm using the example on:
http://www.aspdev.org/articles/asp-getrows/
>>
>> Without GetRows(), the below recordset will return 100+ manufacturer
>> names. With GetRows(), I get nothing.
>> What am I missing?
>
> Without being able to run this against your database I'm not sure how we
> can answer this. But let's see ...
>
>> thanks
>>
>> <%
>> Dim rsManuf
>> Dim rsManuf_numRows
>>
>> Set rsManuf = Server.CreateObject("ADODB.Recordset")
>> rsManuf.ActiveConnection = ConnectString
>
> Nothing to do with your problem but ...
> Extremely Bad Practice. Get out of the habit of doing this now. Always
> open an explicit connection object and use that object to interact with
> the database. Never assign a connection string to an object's
> ActiveConnection property: it defeats the purpose of connection pooling:
>
> dim cn
> set cn=createobject("adodb.connection")
> cn.open connectstring
>
>
>> rsManuf.Source = "{call stp_Manuf}"
>> rsManuf.CursorType = 0
>> rsManuf.CursorLocation = 2
>> rsManuf.LockType = 1
>> rsManuf.Open()
>
> You are going to an awful lot of trouble to open a recordset with the
> default properties. All of the above tasks can be achieved with two
> lines:
>
> Set rsManuf = Server.CreateObject("ADODB.Recordset")
> cn.stp_Manuf rsManuf
>
>
>>
>> rsManuf_numRows = 0
>
> ? Not much point to this line of code
>
>>
>> If Not rsManuf.EOF Then
>> ' Gets all the records
>> arrResultSet = rsManuf.GetRows()
>> End If
>> %>
>> <%
>> rsManuf.Close()
>> Set rsManuf = Nothing
>
> cn.close:set cn=nothing
>
> <snip irrelevant stuff>
>
>> ' Retrieve the total # of rows
>
> You should check to see if arrResultSet is an array before attempting to
> pass it to the UBound function:
>
> If not IsArray(arrResultSet) then
> Response.Write "No data was retrieved"
> else
>
> if it is array, then EOF was not true and your array should contain the
> records returned by stp_Manuf.
> You did not say if you got an error when calling UBound, so i suspect
> your array actually did contain data.
>
>> iRowNumber = ubound(arrResultSet,2)
>>
>> ' Loop through the array holding the result set and display the data
>> For iCounter= 0 to iRowNumber
>> Response.Write(arrResultSet(1,iCounter) & "")
>
> How many fields were returned by stp_Manuf? Don't forget arrays are
> zero-bounded: the 1 in your statement will refer to the second field in
> the resultset, not the first (if that was what you intended).
>
>> Next
>
> I see nothing that should have prevented the code from working, even
> with the poor coding practices. Without being able to test this against
> your database, I do not see how we can help.
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>