May 2002
Beginner
408 pages
9h 10m
English
The most common use for the DataReader is to bind it to Web controls, much in the same way as you'd bind a DataSet. Other than the fact that you've eliminated overhead by not creating a DataSet, binding to a DataReader is almost exactly the same as binding to a DataSet. The code in Listing 8.4 demonstrates how to bind the DataReader. When run, this Web form will appear identical to the one in Figure 8.1. Notice that in line 22, the DataReader object is passed directly to the DataSource of the DataGrid Web control.
<% @Page Language="VB" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <HTML> <HEAD> ... |
Read now
Unlock full access