rs.getrows()

rs.getrows()

am 15.06.2005 21:57:35 von Just1Coder

I was wondering if someone could give me a hand here ...

I have a small sql statement that returns N records in 1 column.

I use getrows to grab them all into an array.

When I test the array it returns true however when I test the ubound
for the array it's 0.


dim sql, nu_array
sql = "select strid from tbl_games_test where nid = 3"
... connection openned ..

nu_array = rs.getrows()

... connection closed ..

when I run the SQL in QA it returns the three rows no problem ...

Win2000 / SQL 2000, Classic ASP if it matters...

Help??

Re: rs.getrows()

am 15.06.2005 22:08:01 von reb01501

J1C wrote:
> I was wondering if someone could give me a hand here ...
>
> I have a small sql statement that returns N records in 1 column.
>
> I use getrows to grab them all into an array.
>
> When I test the array it returns true however when I test the ubound
> for the array it's 0.
>
>
> dim sql, nu_array
> sql = "select strid from tbl_games_test where nid = 3"
> .. connection openned ..
>
> nu_array = rs.getrows()
>
> .. connection closed ..
>
> when I run the SQL in QA it returns the three rows no problem ...
>
> Win2000 / SQL 2000, Classic ASP if it matters...
>
> Help??

You did not show how you attempted to use Ubound ...

You do realize that a getrows array has two dimensions, right? The first
dimension references the column. The second dimension refers to the rows.
So, to find out the number of rows, you would use
ubound(nu_array,2) + 1

Remember, ubound returns the largest index number of the dimension. remember
also that indexes of arrays are zero-based. Hence the "+ 1" in my example.

ubound(nu_array) should return 0 for a recordset that contained a single
column: 0 is the index for the first column.

firstcolumnfirstrowvalue = nu_array(0,0)

firstcoluumnthirdrowvalue = nu_array(0,2)

etc.



--
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: rs.getrows()

am 15.06.2005 22:41:37 von Just1Coder

Sorry ,I was using:
ubound(nu_array,2)

How can I get the values out of the array?

Bob Barrows [MVP] wrote:
> J1C wrote:
> > I was wondering if someone could give me a hand here ...
> >
> > I have a small sql statement that returns N records in 1 column.
> >
> > I use getrows to grab them all into an array.
> >
> > When I test the array it returns true however when I test the ubound
> > for the array it's 0.
> >
> >
> > dim sql, nu_array
> > sql = "select strid from tbl_games_test where nid = 3"
> > .. connection openned ..
> >
> > nu_array = rs.getrows()
> >
> > .. connection closed ..
> >
> > when I run the SQL in QA it returns the three rows no problem ...
> >
> > Win2000 / SQL 2000, Classic ASP if it matters...
> >
> > Help??
>
> You did not show how you attempted to use Ubound ...
>
> You do realize that a getrows array has two dimensions, right? The first
> dimension references the column. The second dimension refers to the rows.
> So, to find out the number of rows, you would use
> ubound(nu_array,2) + 1
>
> Remember, ubound returns the largest index number of the dimension. remember
> also that indexes of arrays are zero-based. Hence the "+ 1" in my example.
>
> ubound(nu_array) should return 0 for a recordset that contained a single
> column: 0 is the index for the first column.
>
> firstcolumnfirstrowvalue = nu_array(0,0)
>
> firstcoluumnthirdrowvalue = nu_array(0,2)
>
> etc.
>
>
>
> --
> 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: rs.getrows()

am 15.06.2005 22:48:07 von Just1Coder

for i = 0 to ubound(nu_array,2)
response.write(nu_array(0,i))
next

Re: rs.getrows()

am 16.06.2005 17:21:52 von Mark Schupp

Do you have an "on error resume next" statement on the page somewhere? if so
comment it out and see if you get an error message.

If not, strip the code down to the bare minimum that reproduces the problem
and post the entire *actual tested code* here (not just snippets). blank out
any passwords or URLs to protect yourself as needed.

--
--Mark Schupp


"J1C" wrote in message
news:1118868487.048599.192440@g44g2000cwa.googlegroups.com.. .
> for i = 0 to ubound(nu_array,2)
> response.write(nu_array(0,i))
> next
>