Link to home
Start Free TrialLog in
Avatar of shankwheat
shankwheatFlag for United States of America

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
SOLUTION
Avatar of Reza Rad
Reza Rad
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial