 |
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

September 27th, 2006, 02:55 PM
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Array Bounds
I'm pulling a 1-dimensional RecordSet into an array. I then call a For Next loop by doing iArr = 0 to UBound(arrShipUserIDs). However, I consistently get Subscript out of bounds errors and don't know why. I only use iArr to reference indeces within the array within the loop. That is why I don't know what's wrong.
Here's my code:
If Not rsShipAddresses.EOF Then arrShipUserIDs = rsShipAddresses.GetRows : iShipCount = 0
iArr = 0
If LBound(arrShipUserIDs) >= 0 Then
For iArr = 0 to (UBound(arrShipUserIDs) - 1)
If arrShipUserIDs(iArr) = 0 Then
iShipCount = iShipCount + 1
End If
Next
If iShipCount = 0 Then
iCounter = iCounter - 1
End If
End If
I had to include the (UBound(arrShipUserIDs) - 1) to get it to stop erroring out. I even wrote out the UBound with Response.Write and for the specific SQL query it is pulling the UBounds results in 0. Could this be the problem?
Specifically it errors on "If arrShipUserIDs(iArr) = 0 Then" only if the UBound(arrShipUserIDs) - 1) isn't in place.
The results on the query are null and I've tried performing Is Nothing checks on arrShipUserIDs(0) but they have resulted in Subscript out of bounds as well.
Any help you can provide is appreciated. If you need anymore details just ask.
Thanks.
|

September 27th, 2006, 03:00 PM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
What happens if you do this:
For iArr = 0 to UBound(arrShipUserIDs)
Response.Write(arrShipUserIDs(iArr))
Next
Dose it cause an error?
--Stole this from a moderator
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
|

September 27th, 2006, 03:04 PM
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes. I've tried that. It still produces the same error.
|

September 27th, 2006, 03:11 PM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Have you tried
For iArr = LBound(arrShipUserIDs) to UBound(arrShipUserIDs)
Next
--Stole this from a moderator
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
|

September 28th, 2006, 07:21 AM
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes, sir, I have.
|

September 28th, 2006, 07:45 AM
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
What do you mean by this:
Write and for the specific SQL query it is pulling the UBounds results in 0. Could this be the problem?
--Stole this from a moderator
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
|

September 28th, 2006, 07:58 AM
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I went into Enterprise Manager and manually executed the same SQL query I was with rsShipAddresses and no results were returned. I also did a Response.Write on the UBound of the array in question and it wrote out zero.
So I'm wondering if it would be the null recordset that could be causing the problem.
|

September 28th, 2006, 08:28 AM
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I just did a Response.Write(rsAddresses.RecordCount) and it results in -1. I can take a gander that this is another meaning "nothing" but what other implications does it have?
|

September 28th, 2006, 08:35 AM
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I'm officially confused. I just manually executed the query that fills rsShipAddresses with different user's values and I got three records back. But then I asked that user to refresh the page he was on / I was editing and the RecordCount still wrote out to -1.
|

September 28th, 2006, 09:01 AM
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I figured it out. Instead of trying to mess with arrays I simply sucked the information I needed from the recordset. Thanks man!!
|
|
 |