shankwheat
asked on
Random Number from value list returned by a DataReader
Hi
My datareader is generating a list of numbers (integers) and I want to randomly pick one of the UserID values from the list and assign it to a label control. I've placed the values for dr("UserID") into an ArrayList thinking this might be the best approach (maybe not) and now I just need to randomly pick one from the ArrayList, myList.
Dim myList As New ArrayList
Try
con.Open()
cmd.Connection = con
dr = cmd.ExecuteReader()
With dr
If .HasRows Then
While .Read
myList.Add(dr("UserId"))
End While
End If
End With
My datareader is generating a list of numbers (integers) and I want to randomly pick one of the UserID values from the list and assign it to a label control. I've placed the values for dr("UserID") into an ArrayList thinking this might be the best approach (maybe not) and now I just need to randomly pick one from the ArrayList, myList.
Dim myList As New ArrayList
Try
con.Open()
cmd.Connection = con
dr = cmd.ExecuteReader()
With dr
If .HasRows Then
While .Read
myList.Add(dr("UserId"))
End While
End If
End With
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.