Slide 7.14: Embedding SQL in ASP.NET (cont.)
Slide 7.16: Embedding SQL in ASP.NET (cont.)
Home

Embedding SQL in ASP.NET (Cont.)


The example below shows a GridView control associated to a SqlDataSource control.

Note that the example was disabled by Microsoft. They are just the screenshots from my computer.


It is a powerful example including the functions of selection, insertion, deletion, and updating. The following SQL statements are used in this application.

01CREATE TABLE  authors (
02  au_id     AUTONUMBER  PRIMARY KEY,
03  au_lname  SHORT TEXT,
04  au_fname  SHORT TEXT,
05  phone     SHORT TEXT,
06  address   SHORT TEXT,
07  city      SHORT TEXT,
08  state     SHORT TEXT,
09  zip       SHORT TEXT,
10  contract  YES/NO );
11 
12SELECT DISTINCT  state  FROM  authors;
13 
14SELECT  au_id, au_lname, au_fname, state
15  FROM  authors  WHERE  state = @state;
16 
17SELECT  au_id, au_lname, au_fname, phone, address, city, state,
18    zip, contract
19  FROM  authors  WHERE  au_id = @au_id;
20 
21UPDATE  authors  SET  au_lname = @au_lname, au_fname = @au_fname,
22    phone = @phone, address = @address, city = @city,
23    state = @state, zip = @zip, contract = @contract
24  WHERE  au_id = @au_id;
25 
26INSERT INTO  authors( au_id, au_lname, au_fname, phone, address,
27    city, state, zip, contract )
28  VALUES( @au_id, @au_lname, @au_fname, @phone, @address, @city,
29    @state, @zip, @contract );
30 
31DELETE FROM  authors  WHERE  au_id = @au_id;