340 likes | 352 Views
This chapter explores creating web applications using ASP.NET, accessing databases, and designing interfaces visually. Topics include connecting to SQL Server and Oracle, configuring data sources, and using grid views for data display. Detailed examples and step-by-step illustrations make it easy to follow along. Whether you are a beginner or looking to enhance your web development skills, this visual approach will help you build dynamic and interactive web applications.
E N D
Chapter 12 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Raymond Frost – John Day – Craig Van Slyke Chapter 12 Accessing Databases from Web Applications with Microsoft ASP.NET Part A
Chapter 12 Active Server Page Model Exhibit 12-1: The Basic Active Server Page Model
Chapter 12 Files for a Web Application Exhibit 12-2: The Active Server Page File Structure
Chapter 12 An Example Web Application Exhibit 12-3: A Simple Web Page
Chapter 12 Web Developer Environment Exhibit 12-4: The Web Developer Development Environment
Chapter 12 Creating a New Web Site Exhibit 12-5: The New Web Site Dialog Box
Chapter 12 Source View Exhibit 12-6: The Initial Display After Creating the Application
Chapter 12 Design View Exhibit 12-7: The Simple Web Application in Design View
Chapter 12 The Toolbar Drag a Button and a Label Control onto the design Exhibit 12-8: Displaying the Toolbox
Chapter 12 The Completed Design Exhibit 12-9: The Design for the Simple Web Application
Chapter 12 Button Control Properties The Text property will be changed to “Time” so that text will be displayed on the button. Exhibit 12-10: The Properties for the Button
Chapter 12 Programming the Button Double-click the button to display the event code associated with the button. Exhibit 12-11: The Code for the Button Click Event
Chapter 12 Intellisense Label1.Text = DateTime.Now Once you type part of the code and reach a period, the drop-down list with available options will be displayed. Exhibit 12-12: Using Intellisense to Enter Code
Chapter 12 Testing the Application When the Time button is clicked, the label will display the current time. Exhibit 12-13: The Results of the Simple Web Application
Chapter 12 The Application to Display a Table Exhibit 12-14: The Application to Display the MEMBER Table
Chapter 12 SqlDataSource Control Drag a copy of the SqlDataSource control to connect the application to a database. Exhibit 12-15: Adding the SqlDataSource Control to the Project
Chapter 12 Common Tasks 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. Exhibit 12-16: Common Tasks for the SqlDataSource Control
Chapter 12 Configure Data Source Wizard First, create a new connection. Exhibit 12-17: Adding the SqlDataSource Control to the Project
Chapter 12 Configure Data Source Wizard Select the type of data source: in this case, Microsoft SQL Server. Exhibit 12-18: Other Data Sources Available for the SqlDataSource Control
Chapter 12 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. Exhibit 12-19: The Add Connection Dialog Box
Chapter 12 Configure Data Source Wizard The newly created connection will be used so just click Next>. Exhibit 12-20: Finishing the Selection of a Connection
Chapter 12 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. Exhibit 12-21: Saving the Connection
Chapter 12 Configure Data Source Wizard A select statement is constructed to retrieve the needed data. Exhibit 12-22: Finishing the Selection of a Connection
Chapter 12 Configure Data Source Wizard The select statement can be tested to make sure it is correct. Exhibit 12-23: Testing the Query
Chapter 12 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. Exhibit 12-24: The GridView Control
Chapter 12 GridView Common Tasks Use the GridView Common Tasks to choose a data source to display through the GridView. Exhibit 12-25: Common GridView Tasks
Chapter 12 Additional Common Tasks 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. Exhibit 12-26: The GridView After Selecting the Data Source
Chapter 12 Auto Formatting When you select a scheme from the list on the left, an example will be displayed at the right. Exhibit 12-27: Auto Format Options for the GridView
Chapter 12 The Finished Design Exhibit 12-28: The Final Design for the Application
Chapter 12 Oracle Data Sources The SqlDataSource can also be used for accessing data in an Oracle database. In the wizard, simply select “Oracle Database”. Exhibit 12-29: Selecting the Oracle Data Source
Chapter 12 Oracle Data Sources To connect to an Oracle database, specify a server name, user name and password. Exhibit 12-30: Setting Connection Properties in the Oracle Data Source
Chapter 12 Oracle Data Sources An Oracle Data Source will be named with the server name and user name. Exhibit 12-31: Selecting an Oracle Data Connection
Chapter 12 Oracle Data Sources Like SQL Server data sources, an Oracle data source can also be saved in the web.config file. Exhibit 12-32: Saving the Oracle Connection
Chapter 12 Oracle Data Sources The select statement for an Oracle database is constructed the same way as SQL Server. Exhibit 12-33: Configuring the Select Statement