I would like to know how can I retrieve results/records from a database one at a time to make it appear in different labels..

eg.
row number 1 of the database's records = apple
lb_fruit.Text = apple

row number 2 of the database's records = pear
lb_fruit2.Text = pear

.
.

And so on..
There's loads of rows that I need to retrieve..
Is there anyway then better then writing loads of sql statements?
Thanks loads in advance. (:

Yes, load them into an array and then for each on the array and display the entire array and build labels as needed.

I would stay away from the array, as there is no need to use more resources since you are already using a datareader to read the data into an array. Your best bet is to put a repeater (depending on your situation and where these labels are placed), and binding it to the repeater.

Dim dtrReader As SqlDataReader = cmdSelect.ExecuteReader()

If dtrReader.HasRows Then
  repeater1.DataSource = dtrReader
  repeater1.DataBind()
End If



------------

<asp:Repeater ID="repeater1" runat="server">
<ItemTemplate>
  <asp:Label ID="lbl" Text='<%# Eval("fruitorColumnName") %>' runat="server" />
  <br />
</ItemTemplate>
</asp:Repeater>

This will spit out information in this manner:

Apple
Banana
Orange
Pear
Zucchini

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.