|
Subject:
|
Array Bounds
|
|
Posted By:
|
mjhoagland
|
Post Date:
|
9/27/2006 2:55:14 PM
|
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.
|
|
Reply By:
|
dparsons
|
Reply Date:
|
9/27/2006 3:00:34 PM
|
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.
|
|
Reply By:
|
mjhoagland
|
Reply Date:
|
9/27/2006 3:04:30 PM
|
Yes. I've tried that. It still produces the same error.
|
|
Reply By:
|
dparsons
|
Reply Date:
|
9/27/2006 3:11:28 PM
|
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.
|
|
Reply By:
|
mjhoagland
|
Reply Date:
|
9/28/2006 7:21:50 AM
|
Yes, sir, I have.
|
|
Reply By:
|
dparsons
|
Reply Date:
|
9/28/2006 7:45:28 AM
|
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.
|
|
Reply By:
|
mjhoagland
|
Reply Date:
|
9/28/2006 7:58:43 AM
|
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.
|
|
Reply By:
|
mjhoagland
|
Reply Date:
|
9/28/2006 8:28:05 AM
|
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?
|
|
Reply By:
|
mjhoagland
|
Reply Date:
|
9/28/2006 8:35:01 AM
|
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.
|
|
Reply By:
|
mjhoagland
|
Reply Date:
|
9/28/2006 9:01:43 AM
|
I figured it out. Instead of trying to mess with arrays I simply sucked the information I needed from the recordset. Thanks man!!
|