NJPhillips
asked on
Add data from recordset to array and sort by date
I have a recordset, "rsTaskinfo" which has a field titled "StatusDateTime" which lists the date/time stamp a person updated their status. What I would like to do is find the last entry entry.... the kicker, is the recordset is already sorted by a persons name, otherwise it would be easy.
My thoughts were to add all of the records to an array and sort that way... but I am not sure if that is very efficient.
What say you experts?
My thoughts were to add all of the records to an array and sort that way... but I am not sure if that is very efficient.
What say you experts?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is a more efficient way as far as the database to throw it into an array but the trade off is a little more complex code.
Do you have 100,000's rows in the database? Do you have 100's of people per minute accessing database? Does the query contain a lot of wild card searches? I think what is "better" is personal preference and use. If the actual usage is small, I think it is easier to go with the simple code.
Without knowing what datafields you need it is hard to give you that option. In short, you would create a dynamic array.
<%
' open rs
Dim demoArray()
Dim counter
counter = 0
do until rs.eof
ReDim Preserve demoArray(i)
DemoArray(counter) = rs.field
if not rs.eof then
counter = counter +1
end if
rs.movenext
loop
'close rs
' now that you have your array, create a function to check the array with each row of data in your display
Function functionName( checkID)
matchID = 0
for each x in demoArray
if x = checkID then
macthID = checkID
end if
next
end function
' the returned matchID can then be used to mark the record with the last update
%>
Do you have 100,000's rows in the database? Do you have 100's of people per minute accessing database? Does the query contain a lot of wild card searches? I think what is "better" is personal preference and use. If the actual usage is small, I think it is easier to go with the simple code.
Without knowing what datafields you need it is hard to give you that option. In short, you would create a dynamic array.
<%
' open rs
Dim demoArray()
Dim counter
counter = 0
do until rs.eof
ReDim Preserve demoArray(i)
DemoArray(counter) = rs.field
if not rs.eof then
counter = counter +1
end if
rs.movenext
loop
'close rs
' now that you have your array, create a function to check the array with each row of data in your display
Function functionName( checkID)
matchID = 0
for each x in demoArray
if x = checkID then
macthID = checkID
end if
next
end function
' the returned matchID can then be used to mark the record with the last update
%>
ASKER
Thanks!