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.

CREATE TABLE  authors (
  au_id     AUTONUMBER  PRIMARY KEY,
  au_lname  SHORT TEXT,
  au_fname  SHORT TEXT,
  phone     SHORT TEXT,
  address   SHORT TEXT,
  city      SHORT TEXT,
  state     SHORT TEXT,
  zip       SHORT TEXT,
  contract  YES/NO );

SELECT DISTINCT  state  FROM  authors;

SELECT  au_id, au_lname, au_fname, state
  FROM  authors  WHERE  state = @state;

SELECT  au_id, au_lname, au_fname, phone, address, city, state,
    zip, contract
  FROM  authors  WHERE  au_id = @au_id;

UPDATE  authors  SET  au_lname = @au_lname, au_fname = @au_fname,
    phone = @phone, address = @address, city = @city,
    state = @state, zip = @zip, contract = @contract
  WHERE  au_id = @au_id;

INSERT INTO  authors( au_id, au_lname, au_fname, phone, address,
    city, state, zip, contract )
  VALUES( @au_id, @au_lname, @au_fname, @phone, @address, @city,
    @state, @zip, @contract );

DELETE FROM  authors  WHERE  au_id = @au_id;