Getting a value every time through the loop

andycharger

Well-known member
Joined
Apr 2, 2003
Messages
152
Hi all!

I need to know how to get a user_id into a variable every time a loop is actioned.

Basically, I am looping through a list of users and need to assign it to a variable everytime.

Here is my code. What do I need to do to get the value out of the datareader?
Code:
        Dim strUserID As String
        Dim oConn2 As SqlConnection
        Dim oComm2 As SqlCommand
        Dim oReader2 As SqlDataReader
        Dim sSQL2 As String
        Dim sConn2 As String

        sSQL2 = "SELECT user_id FROM users "
        sConn2 = ConfigurationSettings.AppSettings("ConnectionString")

        oConn2 = New SqlConnection(sConn2)
        oConn2.Open()

        oComm2 = New SqlCommand(sSQL2, oConn2)
        oReader2 = oComm2.ExecuteReader()

        Do While oReader2.Read

code to go here for my variable I guess!

Any help is most appreciated
 
Solved it myself!!!

All i needed to do was type the reader name and the column name in brackets!!!

i.e.

oReader2("userid")
 
Back
Top