Using the DataReader Class
The DataSet class is a central figure in ADO.NET. However, you have other options for reading data. Suppose, for example, you only want to iterate through a set of data, perhaps browsing. You don't need to scroll back and forth, and you don't need to update the data. You have the option of using a DataReader object for read-only and forward-only data. The DataReader class yields better performance heuristics than the DataSet class for forward-only browsing. The technique for using a DataReader is similar to that for initializing a DataSet.
The DataReader is requested from a command object. We still need a connection, but we don't need an adapter or a DataSet. Listing 11.4 demonstrates how to initialize a command and ...
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