Using the DataReader Object
The DataReader object represents the results of a database query. You get a DataReader by calling a Command object’s ExecuteReader() method.
You can verify whether a DataReader represents any rows by checking the HasRows property or calling the Read() method. The Read() method returns true when the DataReader can advance to a new row. (Calling this method also advances you to the next row.)
The DataReader represents a single row of data at a time. To get the next row of data, you need to call the Read() method. When you get to the last row, the Read() method returns False.
There are multiple ways to refer to the columns returned by a DataReader. For example, imagine that you use a SqlDataReader named reader to represent ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access