8.7. Process the Results of a SQL Query Using a Data Reader

Problem

You need to process the data contained in the System.Data.DbDataReader class instance returned when you execute the DbCommand.ExecuteReader method (see recipe 8-5).

Solution

Use the members of the DbDataReader class to move through the rows in the result set sequentially and access the individual data items contained in each row.

How It Works

The DbDataReader class represents a data reader, which is a forward-only, read-only mechanism for accessing the results of a SQL query. This is a MustInherit class that implements both the System.Data.IDataReader and System.Data.IDataRecord interfaces. Each data provider includes a unique DbDataReader implementation. Here is the list of ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.