DayWalker Posted August 7, 2003 Posted August 7, 2003 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 Quote
Administrators PlausiblyDamp Posted August 7, 2003 Administrators Posted August 7, 2003 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
DayWalker Posted August 7, 2003 Author Posted August 7, 2003 Yeah i noticed my error it is working fine now. Thxs Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.