Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 12 Accessing.

Similar presentations


Presentation on theme: "1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 12 Accessing."— Presentation transcript:

1 1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 12 Accessing Databases from Web Applications with Microsoft ASP.NET Part A Raymond Frost – John Day – Craig Van Slyke

2 2 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Active Server Page Model Exhibit 12-1: The Basic Active Server Page Model

3 3 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Files for a Web Application Exhibit 12-2: The Active Server Page File Structure

4 4 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 An Example Web Application Exhibit 12-3: A Simple Web Page

5 5 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Web Developer Environment Exhibit 12-4: The Web Developer Development Environment

6 6 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Creating a New Web Site Exhibit 12-5: The New Web Site Dialog Box

7 7 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Source View Exhibit 12-6: The Initial Display After Creating the Application

8 8 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Design View Exhibit 12-7: The Simple Web Application in Design View

9 9 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 The Toolbar Exhibit 12-8: Displaying the Toolbox Drag a Button and a Label Control onto the design

10 10 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 The Completed Design Exhibit 12-9: The Design for the Simple Web Application

11 11 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Button Control Properties Exhibit 12-10: The Properties for the Button The Text property will be changed to “Time” so that text will be displayed on the button.

12 12 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Programming the Button Exhibit 12-11: The Code for the Button Click Event Double-click the button to display the event code associated with the button.

13 13 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Intellisense Exhibit 12-12: Using Intellisense to Enter Code Once you type part of the code and reach a period, the drop-down list with available options will be displayed. Label1.Text = DateTime.Now

14 14 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Testing the Application Exhibit 12-13: The Results of the Simple Web Application When the Time button is clicked, the label will display the current time.

15 15 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 The Application to Display a Table Exhibit 12-14: The Application to Display the MEMBER Table

16 16 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 SqlDataSource Control Exhibit 12-15: Adding the SqlDataSource Control to the Project Drag a copy of the SqlDataSource control to connect the application to a database.

17 17 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Common Tasks Exhibit 12-16: Common Tasks for the SqlDataSource Control When you click on the arrow in the upper right corner of the control, the common tasks for that control will be shown. In this case, the next task is to configure the data source.

18 18 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Configure Data Source Wizard Exhibit 12-17: Adding the SqlDataSource Control to the Project First, create a new connection.

19 19 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Exhibit 12-18: Other Data Sources Available for the SqlDataSource Control Configure Data Source Wizard Select the type of data source: in this case, Microsoft SQL Server.

20 20 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Exhibit 12-19: The Add Connection Dialog Box Configure Data Source Wizard For an SQL Server Data Source, select the server: Localhost is for a testing the application against a local copy of SQL Server. Enter the user name and password to gain access to the database. Select the database.

21 21 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Exhibit 12-20: Finishing the Selection of a Connection Configure Data Source Wizard The newly created connection will be used so just click Next>.

22 22 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Exhibit 12-21: Saving the Connection Configure Data Source Wizard Saving the connection will depend on whether your environment allows the use of a web.config file. If not, you can skip this step.

23 23 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Exhibit 12-22: Finishing the Selection of a Connection Configure Data Source Wizard A select statement is constructed to retrieve the needed data.

24 24 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Exhibit 12-23: Testing the Query Configure Data Source Wizard The select statement can be tested to make sure it is correct.

25 25 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 The GridView Control Exhibit 12-24: The GridView Control Once the Data Source control is configured, drag a GridView control onto the design so it can be used to display the data.

26 26 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 GridView Common Tasks Exhibit 12-25: Common GridView Tasks Use the GridView Common Tasks to choose a data source to display through the GridView.

27 27 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Additional Common Tasks Exhibit 12-26: The GridView After Selecting the Data Source Once a data source is selected for the GridView, the common tasks will include additional options for paging, sorting and other features such as Auto Format.

28 28 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Auto Formatting Exhibit 12-27: Auto Format Options for the GridView When you select a scheme from the list on the left, an example will be displayed at the right.

29 29 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 The Finished Design Exhibit 12-28: The Final Design for the Application

30 30 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Oracle Data Sources Exhibit 12-29: Selecting the Oracle Data Source The SqlDataSource can also be used for accessing data in an Oracle database. In the wizard, simply select “Oracle Database”.

31 31 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Exhibit 12-30: Setting Connection Properties in the Oracle Data Source Oracle Data Sources To connect to an Oracle database, specify a server name, user name and password.

32 32 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Exhibit 12-31: Selecting an Oracle Data Connection Oracle Data Sources An Oracle Data Source will be named with the server name and user name.

33 33 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Exhibit 12-32: Saving the Oracle Connection Oracle Data Sources Like SQL Server data sources, an Oracle data source can also be saved in the web.config file.

34 34 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 Exhibit 12-33: Configuring the Select Statement Oracle Data Sources The select statement for an Oracle database is constructed the same way as SQL Server.


Download ppt "1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 12 Accessing."

Similar presentations


Ads by Google