Accessing Database Data from an ASP.NET Web Page

In the examples we've looked at so far, we've been accessing the data in our database through the Web Matrix Project tools. However, our end goal is to have this data displayed on an ASP.NET Web page. This means our ASP.NET Web pages will have to be able to access the data from a database. How is this accomplished? We need to perform the following tasks in our ASP.NET Web page's source code portion:

1.
Connect to the database whose data we are interested in.
2.
Issue a SELECT SQL query.
3.
Retrieve the results from the database.
4.
Display the results.

Realize that before we can work with any database's data, we must first establish what is called a connection, a link between the program that requests ...

Get SAMS Teach Yourself ASP.NET in 24 Hours 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.