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
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