Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset to array

Status
Not open for further replies.

jamesmay

Technical User
Jun 1, 2004
41
GB
Hello, i want to put my record set values into an array but i am a little stuck. this is what i am trying to do...

Code:
Dim TableValues(9,Ubound)
Dim ValueArray(9)

ValueArray(0) = "A"
ValueArray(1) = "B"
ValueArray(2) = "C"
ValueArray(3) = "D"
ValueArray(4) = "E"
ValueArray(5) = "F"
ValueArray(6) = "G"
ValueArray(7) = "H"
ValueArray(8) = "I"

Dim i
for i = 0 to 8
rsData.Source = "Select Distinct "& ValueArray(i) & " from table where (DateStamp BETWEEN '"& StartDate &"' AND '"& EndDate &"') order by "& ValueArray(i) & " asc"
rsData.CursorType = 0
rsData.CursorLocation = 2
rsData.Open()
TableValues(i,Ubound) = rsData.GetRows()
rsData.Close()
next
%>


Please can someone help me?
 
StartDate and EndDate are sting values like...

StartDate = "2005-02-23 16:56"
EndDate = "2005-02-24 16:56"

just fogot to add to the above code.
 
James,

If using dates they should be in the database as dates but seems you have them as strings and you can't search between two dates with strings but can with dates...make sense? If you convert make sure you look up how to set up dates with the # sign. Good luck.


BSL
 
Thanks for replying, the date values are only for testing, forget that bit - im just trying to put values into the same array but at different bits, hope this makes scence? im a bit of a pain.

regards.
 
I don't understand why you are trying to place the recordset's generated array as the i,ubound'th element in your array...?

If you meant TableValues to hold all the information from that one GetRows() call, then you need to assign the GetRows result to the whole variable, not one sub-portion.
Additionally, you should not need (and may not be allowd) to Declare the dimensions of your TableValues array ahead oftime. In fact, since there is no way to know ahead of time how many records will be returned from your recordset, declaring the dimensions will basically just allow you to be wrong 99% of the time (unless you specify a subset of the records during your GetRows call).

Instead, try this:
Code:
Dim TableValues
...
TableValues = rsData.GetRows()
Response.Write "My Table Array has " & UBound(TableValues,2) & " records, with " & UBound(TableValues,1) & " fields/columns per."


-T

[img]http://www.tiernok.com/emoticons/emoticons/barcode_1.gif[/img]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top