Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit

For the SqlDataSource control to be able to retrieve database data, two pieces of information were required: the database's connection string and the query to issue to the database. As we discussed in the preceding section, the query issued to the database must be in a dialect that the database understands. The common dialect among all modern database systems is SQL, or the Structured Query Language.

To retrieve data from a database, we use a SQL SELECT statement. The SELECT statement, in its simplest form, specifies what database table to retrieve data from, along with what columns of data to return. For example, to return the title of each book in the Books table, we would use the following SQL statement:

SELECT Title FROM Books

We will examine the SQL SELECT clause in great detail in the next section.

Although SQL is used primarily for retrieving database data, it can also be used to insert new data and update or delete existing data. These data modification capabilities are expressed using INSERT, UPDATE, and DELETE statements.

By the Way

In this hour we will focus strictly on using SQL to retrieve data. However, starting in Hour 16, "Deleting, Inserting, and Editing Data," we will examine how to delete and edit database data.

Категории