asp.net.ph

Skip Navigation LinksHome > Data Access / ADO.NET > Displaying information from a database

Displaying information from a database

Accessing Data with ADO.NET


ASP.NET provides a rich set of controls that are well-integrated with the data access interface provided by ADO.NET. This section provides information on how you can use ASP.NET server controls to bind to the results of SQL queries and XML data files.

In particular, this document steps through code examples that use the ASP.NET templated controls — <asp:Repeater>, <asp:DataList>, and <asp:DataGrid> controls — to display the results of database queries fetched into an instance of the DataReader class.

These samples demonstrate how you can use the simple power of the ASP.NET databinding model, to dynamically generate the column values within each row of a DataReader into the corresponding items of said controls.

Binding a DataReader to a Repeater
Run Sample | View Source
Binding a DataReader to a DataList
Run Sample | View Source
Binding a DataReader to a DataGrid
Run Sample | View Source

Note that for all the samples, we are using a DataReader to bind directly to the controls. DataReaders retrieve a read-only, forward-only stream of data from a database, and are appropriate when the need is to simply "read" the results after executing a query to the data source. Any of these samples, though, could be re-written to use a DataSet as well.

The material covered in this section assumes some familiarity with database fundamentals and the Structured Query Language ( SQL ). And if you haven’t done so, I suggest you start with the ADO.NET Primer.

Now let’s take a closer look at how all these are done.

More ...
Back to top


© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note