This question is a follow up to an earlier question I had that was quickly resolved. The previous question can be found here: Selecting TOP 4 records from multiple SQL Server tables. Using vb.net
I selected the top 4 rows from multiple SQL tables ordered by date. How would I then go about placing that data into labels. There should be 16 items in total (4 columns, 4 rows). However if I try to use sqldatareader I only get items 0-3 and anything more is outside of the array. Should I not be using an IF statement in this case? Thanks in advance for any assistance. This site is great.
In addition to the newly formed select statement based on the previously linked question, here is what I have:
If dr2.Read Then
slidelink1.Text = dr2.Item(0)
slideanchor1.Text = dr2.Item(1)
slidethumb1.Text = dr2.Item(2)
slidedate1.Text = dr2.Item(3)
End If
I appreciate the help guys, as always. Don’t hesitate to tell me if I am way off base here. I’m assuming the reader is only displaying the final row of data, but I’m pretty fresh to this stuff.
what if you just called Read 4 times.
You could also loop, but if you always know that there are 4 in the result it might be easier to just do it this way.