May 2002
Beginner
408 pages
9h 10m
English
The DataReader offers more granular control of database records than just data binding, however. By using the Read() method of the DataReader object, you can step through each record of the resultset individually. This is akin to the old days of stepping through each record in a recordset using ADO. This gives you the ability to process each record with as much precision as you need.
Listing 8.5 demonstrates how to use a DataReader to pull back data and retrieve individual fields. This example uses some interesting DataReader methods, such as GetOrdinal(), to facilitate the retrieval of the information. When run, the example in Listing 8.5 (VB .NET) and Listing 8.6 (C#) will look like Figure 8.2.
Read now
Unlock full access