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?
thanks

<%
Dim rsManuf
Dim rsManuf_numRows

Set rsManuf = Server.CreateObject("ADODB.Recordset")
rsManuf.ActiveConnection = ConnectString
rsManuf.Source = "{call stp_Manuf}"
rsManuf.CursorType = 0
rsManuf.CursorLocation = 2
rsManuf.LockType = 1
rsManuf.Open()

rsManuf_numRows = 0

If Not rsManuf.EOF Then
' Gets all the records
arrResultSet = rsManuf.GetRows()
End If
%>
<%
rsManuf.Close()
Set rsManuf = Nothing
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<%
' Retrieve the total # of rows
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) & "")
Next
%>
</body>
</html>

Re: GetRows by Bob

Bob
Thu Mar 13 13:38:27 CDT 2008

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.



Re: GetRows by shank

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.
>
>



Re: GetRows by daddywhite

daddywhite
Thu Mar 13 14:24:18 CDT 2008

The code that shank showed was auto produced by dreamweaver 8 - maybe
Bob could re-write that code according to "best practice" with
comments and we can compare?

Re: GetRows by Bob

Bob
Thu Mar 13 14:28:32 CDT 2008

shank wrote:
>>> Response.Write(arrResultSet(1,iCounter) & "")<<
> That was the problem,
> Should have been...
> Response.Write(arrResultSet(0,iCounter) & "")


And, fo future reference, if you had provided an error message and
indicated which line threw the error, it would have been a much simpler
diagnosis.
--
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.



Re: GetRows by Bob

Bob
Thu Mar 13 14:54:21 CDT 2008

daddywhite wrote:
> The code that shank showed was auto produced by dreamweaver 8 - maybe

Really? I didn't see any of those mm_ variables. How did you determine
this?

> Bob could re-write that code according to "best practice" with
> comments and we can compare?

Well, isn't that what I just did? You want me to do it again? :-)

--
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.



Re: GetRows by shank

shank
Thu Mar 13 15:07:04 CDT 2008

There was no error. Just an empty screen.
thanks

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:%23HjJuBUhIHA.1208@TK2MSFTNGP03.phx.gbl...
> shank wrote:
>>>> Response.Write(arrResultSet(1,iCounter) & "")<<
>> That was the problem,
>> Should have been...
>> Response.Write(arrResultSet(0,iCounter) & "")
>
>
> And, fo future reference, if you had provided an error message and
> indicated which line threw the error, it would have been a much simpler
> diagnosis.
> --
> 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.
>
>



Re: GetRows by shank

shank
Thu Mar 13 15:08:29 CDT 2008

It was generated by DW, but I usually change the MM variables to something
else. Habit I guess...


"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:O4bgJQUhIHA.4140@TK2MSFTNGP04.phx.gbl...
> daddywhite wrote:
>> The code that shank showed was auto produced by dreamweaver 8 - maybe
>
> Really? I didn't see any of those mm_ variables. How did you determine
> this?
>
>> Bob could re-write that code according to "best practice" with
>> comments and we can compare?
>
> Well, isn't that what I just did? You want me to do it again? :-)
>
> --
> 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.
>
>



Re: GetRows by Bob

Bob
Thu Mar 13 15:26:09 CDT 2008

Then you must have had "on error resume next" masking the error.

shank wrote:
> There was no error. Just an empty screen.
> thanks
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:%23HjJuBUhIHA.1208@TK2MSFTNGP03.phx.gbl...
>> shank wrote:
>>>>> Response.Write(arrResultSet(1,iCounter) & "")<<
>>> That was the problem,
>>> Should have been...
>>> Response.Write(arrResultSet(0,iCounter) & "")
>>
>>
>> And, fo future reference, if you had provided an error message and
>> indicated which line threw the error, it would have been a much
>> simpler diagnosis.
>> --
>> 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.

--
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.



Re: GetRows by daddywhite

daddywhite
Thu Mar 13 15:31:34 CDT 2008

> Really? I didn't see any of those mm_ variables. How did you determine
this?

the layout of the variables and the pointlessness of rsManuf_numRows =
0 was classic DW.

>Well, isn't that what I just did? You want me to do it again? :-)

Just thought it would be handy to see your interpretation of best
practice for the code all as one chunk thats all.

regards

Re: GetRows by shank

shank
Thu Mar 13 16:46:53 CDT 2008

>>on error resume next<<
Again, you are correct. I have it inside an include file and ignored the
possibility of its presence.
sorry!

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:OpQc6hUhIHA.4396@TK2MSFTNGP04.phx.gbl...
> Then you must have had "on error resume next" masking the error.
>
> shank wrote:
>> There was no error. Just an empty screen.
>> thanks
>>
>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>> news:%23HjJuBUhIHA.1208@TK2MSFTNGP03.phx.gbl...
>>> shank wrote:
>>>>>> Response.Write(arrResultSet(1,iCounter) & "")<<
>>>> That was the problem,
>>>> Should have been...
>>>> Response.Write(arrResultSet(0,iCounter) & "")
>>>
>>>
>>> And, fo future reference, if you had provided an error message and
>>> indicated which line threw the error, it would have been a much
>>> simpler diagnosis.
>>> --
>>> 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.
>
> --
> 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.
>
>



Re: GetRows by Bob

Bob
Fri Mar 14 10:50:55 CDT 2008

daddywhite wrote:
>> Well, isn't that what I just did? You want me to do it again? :-)
>
> Just thought it would be handy to see your interpretation of best
> practice for the code all as one chunk thats all.
>
> regards

OK ..

<%
dim cn, rs, arData, i
set cn=createobject("adodb.connection")
on error resume next
cn.open connectstring
if err<>0 then
'handle the error - notify user, destroy cn object
on error goto 0
else
Set rs = CreateObject("ADODB.Recordset")
cn.stp_Manuf rs
if err<> 0 then
'handle the error - notify user, close&destroy cn object
on error goto 0
else
on error goto 0
if not rs.eof then arData = rs.GetRows
rs.close: set rs=nothing
cn.close: set cn=nothing
if IsArray(arData) then
for i = 0 to ubound(arData,2)
Response.Write arData(0,i) & "<br>"
next
else
Response.Write "No records returned"
end if
end if
end if
%>

--
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.