DataReader Urgent!! pls

DayWalker

Well-known member
Joined
Jul 9, 2003
Messages
51
I am quite new to .Net and i am trying to get the results row for row out of a Select statement and bind each row to a label. At the moment my code looks like this :

VB: Dim cmd As New SqlCommand("SELECT names, email FROM Employees, UnitsConn)
Dim i As Integer

UnitsConn.Open()
Dim drItems As SqlDataReader = cmd.ExecuteReader()

If drItems.HasRows Then

While drItems.Read

lblHW1.Text = drItems.Item("Names")
lblSN1.Text = drItems.Item("Email")
lblHW2.Text = drItems.Item("Names")
lblSN2.Text =drItems.Item("Email")

end while
end if
UnitsConn.Close

The problem is it is just returning th elast result in the table.

PLEASE Help
 
Not exactly sure what you are trying to do there. Because you are doing the .Text assignments within the

While drItems.Read

loop it will overwrite the contents repeatedly till the loop exits. The last record will be the one that is displayed.
 
Back
Top