JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Using Data Readers

As with Windows forms, you can use data readers to access data, not just datasets (see "Using a Data Reader" in Chapter 22 for more on data readers). To see how this works, see the WebDataReader example on the CD-ROM. In that example, I use an OleDbCommand object to retrieve the authors table and connect that table to a data grid. Here's the code—note that you use the ExecuteReader method of the command object to get the data reader:

Private Sub Page_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
    Dim Reader1 As System.Data.OleDb.OleDbDataReader
    Reader1 = OleDbCommand1.ExecuteReader()
    DataGrid1.DataSource = Reader1
End Sub

You can see the results in Figure 23.12, where the data from the data reader is displayed in the data grid in this example.

Click To expand
Figure 23.12: The WebDataReader example.

Related solution:

Found on page:

Using a Data Reader


Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor