VBScript UBound shows 0 ??

Hello,

I'm having issues with Ubound...

It is returning 3, when there are only 2 records in the database...

The VBScript reads like this --

<%
dim bannercount

Dim cmdbanner__Brand
cmdbanner__Brand = NULL
if(Request("Brand") <> "") then cmdbanner__Brand = Request("Brand")

set cmdbanner = Server.CreateObject("ADODB.Command")
cmdbanner.ActiveConnection = MM_GolfConnection_STRING
cmdbanner.CommandText = "dbo.PriceGuideBannerDisplay"
cmdbanner.CommandType = 4
cmdbanner.CommandTimeout = 0
cmdbanner.Prepared = true
cmdbanner.Parameters.Append cmdbanner.CreateParameter("@RETURN_VALUE", 3, 4)
cmdbanner.Parameters.Append cmdbanner.CreateParameter("@Brand", 3, 1,4,cmdbanner__Brand)
set RsBanners = cmdbanner.Execute
RsBanners_numRows = 0

If not RsBanners.eof then
arrBanners = RsBanners.GetRows()
bannercount = UBound(arrBanners)
End if 

RsBanners.Close() 'Clean Up
Set RsBanners = Nothing 'Clean Up
Set cmdbanner = Nothing 'Clean Up
%>

Open in new window


And the database Query is like so --

CREATE PROCEDURE [dbo].[PriceGuideBannerDisplay]
(
@Brand int
)
AS
BEGIN
SET NOCOUNT ON;
IF @Brand IS NOT NULL
BEGIN
SELECT [ID], [Brand], [Filename], [ShowOnHome] FROM [dbo].[PriceGuideBanner] Where Brand = @Brand
END
ELSE
BEGIN
SELECT [ID], [Brand], [Filename], [ShowOnHome] FROM [dbo].[PriceGuideBanner] Where ShowOnHome = 'Y'
END
END

GO

Open in new window


I'm sending no Brand parameter, so the results should be the two records on the database that have ShowOnHome = 'Y'

So surely, bannercount should be 1?

Help!!!

Thanks
garethtnashAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ken ButtersCommented:
Check the values you are getting in your result set.

Which rows from the DB are being returned?  that might help give you a clue as to what's happening.
0
garethtnashAuthor Commented:
2 rows, 4 columns...

rows with ID 5 & 8

Very confused?

UBound does count rows?
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
bannercount = UBound(arrBanners,2)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

garethtnashAuthor Commented:
Thank you
0
Ken ButtersCommented:
Looks like getRows returns a 2 dimensional Array.

It looks like you are getting the UBound of the number of columns.  4 columns with a starting array index of zero... gives you the 3 you are getting.

try UBound(arrBanners,2) :  In order to get the Ubound of the 2nd dimension of the array, which should be the number of rows.
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
To keep things easy, in my for next loop, I assign variables instead of trying to keep track of which row and column I am on for accessing the array.  Using code like below, you can use a variable inside of a for next loop.

for r = LBound(arrBanners, 2) To UBound(arrBanners, 2)
    	ID= arrBanners(0, r)
	Brand = arrBanners(1, r)
	FileName = arrBanners(2, r)
	ShowOnHome = arrBanners(3, r)


      response.write "Brand= "&Brand&"<br>"
next

Open in new window

0
garethtnashAuthor Commented:
that's neat - thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.