Question

I'm using a DataReader to display informations stored in a table.

I created Two button to go to next record and to go back.

In VB6 I used this code :

While Not Recordset1.EOF
Recordset1.MoveNext
End While

In ASP.NET I didn't find a way to do like it, because DataReader hasn't the EOF property.

EDIT :

While Not Recordset1.BOF
Recordset1.MovePrevious
End While

How can I convert this last code (VB6) to ASP.NET ??

Was it helpful?

Solution

You use Read instead of MoveNext and it'll return false if there aren't any more records. So:

While rdr.Read()
    .... ' process this row
End While

OTHER TIPS

Azirar, ho1 is correct in that you should use a DataTable. If you're updating after every post back and only need a single record you could still use a DataReader, but set up your SQL statement to get a single row (storing the appropriate information needed in your SQL statement (or better yet stored procedure) to get that single record back within query strings or session variables).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top