Presentation is loading. Please wait.

Presentation is loading. Please wait.

© Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining.

Similar presentations


Presentation on theme: "© Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining."— Presentation transcript:

1 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining the Database and Creating Database Components Outline 30.1 Reviewing the Bookstore Application 30.2 Information Tier: Database 30.3 Using the Server Explorer and Query Builder in ASPX Pages 30.4 Wrap-Up

2 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 2 Objectives In this tutorial, you will learn to: –Connect to a database. –Create SQL statements that retrieve information from a database, using the Query Builder tool.

3 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 3 30.1 Reviewing the Bookstore Application

4 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 4 30.2 Information Tier: Database Information tier –Maintains all of the data needed for an application –Integral to real-world applications because they can update data in real time Bookstore application’s information tier –The Bookstore application stores the books’ data in a Microsoft Access database ( db_bookstore.mdb ) –Data is retrieved from the database using C# code and ADO.NET objects

5 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 5 30.2 Information Tier: Database Figure 30.2 Products table of the db_bookstore.mdb database. Products table of the db_bookstore.mdb database Products table contains nine columns

6 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 6 30.3 Using the Server Explorer and Query Builder in ASPX Pages Figure 30.3 Connecting to the database in the Server Explorer window. Connect to database icon To create the database connections that retrieve data from the database and to generate SQL statements to request book information, you must use the Server Explorer window and the Query Builder tool

7 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 7 Figure 30.4 Data Link Properties dialog’s Provider tab. 30.3 Using the Server Explorer and Query Builder in ASPX Pages Provider tab Select this provider Specify the provider of the database software you are using

8 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 8 Figure 30.5 Data Link Properties dialog’s Connection tab. 30.3 Using the Server Explorer and Query Builder in ASPX Pages Connection tab Click ellipsis Button to select the database

9 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 9 Figure 30.6 Select Access Database dialog. 30.3 Using the Server Explorer and Query Builder in ASPX Pages Select db_bookstore. mdb database

10 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 10 Figure 30.7 Testing the database connection. Click to test connection 30.3 Using the Server Explorer and Query Builder in ASPX Pages Location of database Click OK in Data Link Properties to add your database connection to the Server Explorer window

11 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 11 Figure 30.8 Query Builder and Add Table dialogs for the Bookstore application. 30.3 Using the Server Explorer and Query Builder in ASPX Pages Click to add tableSelect Products Clicking the ellipsis (…) next to the CommandText field of an OleDbCommand object on an ASPX page causes these dialogs to appear

12 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 12 Figure 30.9 Query Builder displaying the selected title field. 30.3 Using the Server Explorer and Query Builder in ASPX Pages SELECT statement that returns all book titles in the Products table Products window Check title Checkbox Values for this row now appear Clicking the title CheckBox creates this SELECT statement

13 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13 30.3 Using the Server Explorer and Query Builder in ASPX Pages Use the Parameters property of a data command object if its reference is not yet known You can program the application to specify the reference during execution

14 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 14 Figure 30.10 Query Builder and Add Table dialogs. 30.3 Using the Server Explorer and Query Builder in ASPX Pages Add Table dialog Add this table

15 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 15 Figure 30.11 Adding fields to the SELECT statement 30.3 Using the Server Explorer and Query Builder in ASPX Pages Fields added to SELECT statement Notice that the field names appear after the SELECT keyword in the SELECT statement as well as in the table

16 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 16 Figure 30.12 Specifying Criteria value for the title row. 30.3 Using the Server Explorer and Query Builder in ASPX Pages Add this value to the Criteria column Remove this check mark Type “ =? ” in the Criteria field if you do not know the record from which the information will be retrieved

17 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 17 Figure 30.13 Removing the title field from the SELECT portion of the SQL statement. Check mark removed 30.3 Using the Server Explorer and Query Builder in ASPX Pages Complete SELECT statement

18 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 18 Figure 30.14 Microsoft Development Environment dialog. 30.3 Using the Server Explorer and Query Builder in ASPX Pages After you click OK in the Query Builder this dialog appears asking if you want to apply a new parameter configuration –Click Yes

19 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 19 Figure 30.15 Parameters property of objSelectBookData. 30.3 Using the Server Explorer and Query Builder in ASPX Pages Parameters property Click to view the collection To verify that the parameter was created correctly, click the ellipsis (…) next to the Parameters field

20 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 20 Figure 30.16 OleDbParameter Collection Editor dialog. title parameter created 30.3 Using the Server Explorer and Query Builder in ASPX Pages Name of the parameter This dialog displays the parameters of a data command object


Download ppt "© Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining."

Similar presentations


Ads by Google