Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...