You don't use a loop.
Exactly how to do this depends on a number of factors, such as how you are fetching your data, how much data is involved, and what exactly your DB contains.
But one way would be:
Make sure your DB contains an Id column, with is IDENTITY.
Set up a class level int in your DB called
lastRow
and set it to -1.
When you fetch a single row from the DB to display, use something like:
SELECT TOP 1 * FROM MyTable WHERE Id > lastRow ORDER BY ID ASC
If you get any rows, load lastRow with the ID value.
For "Next" it's the same query.
For previous its:
SELECT TOP 1 * FROM MyTable WHERE Id < lastRow ORDER BY ID DESC
First:
SELECT TOP 1 * FROM MyTable ORDER BY ID ASC
Lst:
SELECT TOP 1 * FROM MyTable ORDER BY ID DESC