Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.

Slides:



Advertisements
Similar presentations
Data Base. Objective Become familiar with database terminology. Create a project to display data for a single database table. Use a DataGrid control.
Advertisements

Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
 Open the Paradise.exe file  Application displays records in the Books database  Allows the store manager to enter an author’s name (or part of a name)
Chapter 12: Using ADO.NET 2.0 Programming with Microsoft Visual Basic 2005, Third Edition.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
1 Chapter 12 Working With Access 2000 on the Internet.
Integrating Access with the Web and with Other Programs.
Automating Tasks With Macros
Using ADO.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
1 Pertemuan 09 Database Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Chapter 14: Advanced Topics: DBMS, SQL, and ASP.NET
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
Tutorial 11: Connecting to External Data
XP New Perspectives on Microsoft Access 2002 Tutorial 71 Microsoft Access 2002 Tutorial 7 – Integrating Access With the Web and With Other Programs.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Some Basic Database Terminology
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
Databases and LINQ Visual Basic 2010 How to Program 1.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
ASP.NET Programming with C# and SQL Server First Edition
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Chapter 10 Accessing Database Files Programming In Visual Basic.NET.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Creating Web Applications Using ASP.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Twelve Access Databases and LINQ.
CHAPTER EIGHT Accessing Data Processing Databases.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Thirteen Working with Access Databases and LINQ.
CHAPTER EIGHT Accessing Data Processing Databases.
Key Applications Module Lesson 21 — Access Essentials
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 8 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 8 Creating.
Tutorial 91 Databases A database is an organized collection of related information stored in a file on a disk A database allows companies to store information.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
Introduction to ADO.Net and VS Database Tools and Data Binding ISYS 350.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
BlackBerry Applications using Microsoft Visual Studio and Database Handling.
Databases and ADO.NET Programming Right from the Start with Visual Basic.NET 1/e 11.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 12 Accessing.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 25 I’m Suffering from Information Overload.
Chapter 24 I’m Suffering from Information Overload (Access Databases) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Chapter 27 Getting “Web-ified” (Web Applications) Clearly Visual Basic: Programming with Visual Basic nd Edition.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 8 1 Microsoft Office Access 2003 Tutorial 8 – Integrating Access with the.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 350.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
CHAPTER 7 LESSON C Creating Database Reports. Lesson C Objectives  Display image data in a report  Manually create queries and data links  Create summary.
Programming with Microsoft Visual Basic 2012 Chapter 14: Access Databases and SQL.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Microsoft Visual Basic 2010: Reloaded Fourth Edition
ADO.NET Accessing Databases in VS.NET
Brief description on how to navigate within this presentation (ppt)
Microsoft Office Access 2003
Microsoft Office Access 2003
CIS16 Application Programming with Visual Basic
Database Applications
Tutorial 7 – Integrating Access With the Web and With Other Programs
Chapter 10 Accessing Database Files
Programming with Microsoft Visual Basic 2008 Fourth Edition
Introduction to ADO.Net and Visual Studio Database Tools.
Presentation transcript:

Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition

2 Database Terminology Lesson A Objectives Define the terms used when talking about databases Explain the purpose of the DataAdapter, Connection, and DataSet objects Explain the role of the provider Create and configure an OleDbDataAdapter object

Programming with Microsoft Visual Basic.NET, Second Edition 3 Database Terminology Lesson A Objectives (continued) Write SQL SELECT statements Create a dataset Display a dataset in a DataGrid control

Programming with Microsoft Visual Basic.NET, Second Edition 4 Database Terminology (continued) Database: organized collection of related information stored in a file on a disk Relational database: database that stores information in tables –Each column represents a field –Each row represents a record

Programming with Microsoft Visual Basic.NET, Second Edition 5 Database Terminology (continued) Table: a group of related records Each record in a table pertains to the same topic, and each contains the same type of information Relational database contains one or more tables Primary key: a field that uniquely identifies each record in a table

Programming with Microsoft Visual Basic.NET, Second Edition 6 Database Terminology (continued) Figure 12-3: Example of a two-table relational database

Programming with Microsoft Visual Basic.NET, Second Edition 7 Database Terminology (continued) In Figure 12-3: –The first table is called the parent table –The second table is called the child table –In the parent table, the Number field is the primary key –In the child table, the Number field is called the foreign key

Programming with Microsoft Visual Basic.NET, Second Edition 8 ADO.NET To connect an application to a database, Visual Basic.NET uses ADO.NET With ADO.NET, the connection between an application and a database is a temporary one Use three ADO.NET objects and a provider to access a database from a Visual Basic.NET application –DataAdapter, Connection, and DataSet

Programming with Microsoft Visual Basic.NET, Second Edition 9 ADO.NET (continued) Figure 12-4: Illustration of the relationships among an application, the ADO.NET objects, a provider, and a database

Programming with Microsoft Visual Basic.NET, Second Edition 10 Creating and Configuring a DataAdapter Object The DataAdapter object is the link between the application and the Connection object DataAdapter object contacts the Connection object whenever the application needs to read data from or write data to a database

Programming with Microsoft Visual Basic.NET, Second Edition 11 Creating and Configuring a DataAdapter Object (continued) Figure 12-6: Procedure for creating and configuring a DataAdapter object for a Microsoft Access database

Programming with Microsoft Visual Basic.NET, Second Edition 12 Creating and Configuring a DataAdapter Object (continued) Figure 12-6: Procedure for creating and configuring a DataAdapter object for a Microsoft Access database (continued)

Programming with Microsoft Visual Basic.NET, Second Edition 13 SQL SQL (Structured Query Language): a set of commands to access and manipulate the data stored in many database management systems SQL commands perform database tasks such as storing, retrieving, updating, deleting, and sorting

Programming with Microsoft Visual Basic.NET, Second Edition 14 SQL (continued) SELECT statement allows you to: –Specify the fields and records you want to view –Control the order in which the fields and records appear when displayed

Programming with Microsoft Visual Basic.NET, Second Edition 15 SQL (continued) Figure 12-13: Syntax and examples of the SELECT statement

Programming with Microsoft Visual Basic.NET, Second Edition 16 SQL (continued) Figure 12-13: Syntax and examples of the SELECT statement (continued)

Programming with Microsoft Visual Basic.NET, Second Edition 17 Using the Query Builder to Enter a SELECT Statement When you click the Next > button on the Choose a Query Type screen, the Generate the SQL statements screen appears You can enter the SELECT statement yourself, or you can have the Query Builder enter it for you To use the Query Builder, click the Query Builder button –The Query Builder and Add Table dialog boxes open

Programming with Microsoft Visual Basic.NET, Second Edition 18 Using the Query Builder to Enter a SELECT Statement (continued) Figure 12-15: Query Builder and Add Table dialog boxes

Programming with Microsoft Visual Basic.NET, Second Edition 19 Using the Query Builder to Enter a SELECT Statement (continued) Figure 12-18: SELECT statement entered in the Generate the SQL statements screen

Programming with Microsoft Visual Basic.NET, Second Edition 20 Creating a Dataset A dataset contains the data you want to access from the database, as specified in the SELECT statement associated with the DataAdapter object XML (Extensible Markup Language): a text- based language used to store and share data between applications and across networks and the Internet An XML schema definition file defines the tables and fields that make up the dataset

Programming with Microsoft Visual Basic.NET, Second Edition 21 Creating a Dataset (continued) Figure 12-21: Procedure for creating a dataset

Programming with Microsoft Visual Basic.NET, Second Edition 22 Using the Fill Method Use the DataAdapter object’s Fill method to fill a dataset with data while an application is running Figure 12-25: Syntax and an example of the Fill method

Programming with Microsoft Visual Basic.NET, Second Edition 23 Binding the DataSet Object to a DataGrid Control View the data contained in a dataset by connecting its DataSet object to one or more controls in the interface Binding: Connecting a DataSet object to a control Bound controls: the connected controls Bind a control using one or more properties listed in the Properties window

Programming with Microsoft Visual Basic.NET, Second Edition 24 Binding the DataSet Object to a DataGrid Control (continued) Figure 12-26: Procedure for binding a DataSet object to a DataGrid control

Programming with Microsoft Visual Basic.NET, Second Edition 25 Binding the DataSet Object to a DataGrid Control (continued) When bound to a DataSet object, the DataGrid control displays the data from the dataset in a row and column format –Each field in the dataset appears in a column in the DataGrid control –Each record in the dataset appears in a row in the DataGrid control

Programming with Microsoft Visual Basic.NET, Second Edition 26 Reconfiguring the DataAdapter Object Figure 12-30: Procedure for reconfiguring an existing DataAdapter object

Programming with Microsoft Visual Basic.NET, Second Edition 27 More on Binding Controls Lesson B Objectives Display a dataset in various controls in an interface Position the record pointer in a dataset

Programming with Microsoft Visual Basic.NET, Second Edition 28 Binding the DataSet Object to a Label Control or a Text Box Figure 12-33: Procedure for binding a DataSet object to a label control or text box

Programming with Microsoft Visual Basic.NET, Second Edition 29 Coding the Cartwright Industries Application Carl Simons, the sales manager at Cartwright Industries, records the item number, name, and price of each product the company sells in a database named Items.mdb Items.mdb database –Contains one table named tblItems –The Number and Name fields contain text, and the Price field contains numbers

Programming with Microsoft Visual Basic.NET, Second Edition 30 Coding the Cartwright Industries Application (continued) Figure 12-37: Items.mdb database opened in Microsoft Access

Programming with Microsoft Visual Basic.NET, Second Edition 31 Coding the Cartwright Industries Application (continued) Figure 12-39: TOE chart for the Cartwright Industries application

Programming with Microsoft Visual Basic.NET, Second Edition 32 Creating Web Applications Using ASP.NET Lesson C Objectives Define the terms used when talking about the Web Create a Web application Add controls to a Web form Start a Web application

Programming with Microsoft Visual Basic.NET, Second Edition 33 Creating Web Applications Using ASP.NET Lesson C Objectives (continued) Use the validator controls Include a list box on a Web form Determine whether a postback has occurred Include a DataGrid control on a Web form

Programming with Microsoft Visual Basic.NET, Second Edition 34 Web Terminology The Internet is the world’s largest computer network, connecting millions of computers located all around the world World Wide Web (WWW or the Web) –Part of the Internet –Consists of documents called Web pages that are stored on Web servers

Programming with Microsoft Visual Basic.NET, Second Edition 35 Web Terminology (continued) Web server: computer that contains software that “serves up” Web pages in response to requests from clients A client is a computer that requests information from a Web server The information is requested and subsequently viewed through the use of a program called a Web browser (or simply, a browser)

Programming with Microsoft Visual Basic.NET, Second Edition 36 Web Terminology (continued) Figure 12-49: Illustration of the relationship between a client, a browser, and a Web server

Programming with Microsoft Visual Basic.NET, Second Edition 37 Web Terminology (continued) Static Web page: document whose purpose is merely to display information to the viewer Dynamic Web page is interactive; it can accept information from the user and also retrieve information for the user Every Web page has a unique address called a URL (Uniform Resource Locator) that indicates its location on the Web

Programming with Microsoft Visual Basic.NET, Second Edition 38 Creating Web Applications Use a Web form to create a Web page in Visual Basic.NET Create (or design) the Web page in the Web Form Designer window

Programming with Microsoft Visual Basic.NET, Second Edition 39 Creating Web Applications (continued) Figure 12-52: Procedure for creating a Web application

Programming with Microsoft Visual Basic.NET, Second Edition 40 Adding Controls to a Web Form Use the tools contained in the Toolbox window to add controls to a Web form The tools for a Web form are located on the Web Forms tab in the toolbox Can add a control to a Web form by simply dragging the corresponding tool from the Web Forms tab to the form

Programming with Microsoft Visual Basic.NET, Second Edition 41 Using the Web Validator Tools These tools allow you to validate user input Figure 12-65: The Web validator tools

Programming with Microsoft Visual Basic.NET, Second Edition 42 Including a List Box on a Web Form Use the ListBox tool on the Web Forms tab to add a list box to a Web form Can use a list box on a Web form to display a list of choices from which the user can select one or more choices

Programming with Microsoft Visual Basic.NET, Second Edition 43 Including a List Box on a Web Form (continued) A postback refers to the client requesting data from the server, and the server responding Each time a postback occurs, the Web page is redisplayed on the client’s screen Can use the Web form’s IsPostBack property to determine if the Web form is being displayed for the first time or as a result of a postback

Programming with Microsoft Visual Basic.NET, Second Edition 44 Including a DataGrid Control on a Web Form DataGrid control displays the data from a dataset in a row and column format Each field in the dataset appears in a column in the DataGrid control, and each record appears in a row The DataGrid control’s DataBind method is used to bind the control to the dataset

Programming with Microsoft Visual Basic.NET, Second Edition 45 Including a DataGrid Control on a Web Form (continued) Figure 12-72: Web form for the Fairview application

Programming with Microsoft Visual Basic.NET, Second Edition 46 Including a DataGrid Control on a Web Form (continued) DataGrid control provides many properties to control the appearance of its output DataGrid control provides an Auto Format dialog box that allows selection from a list of predefined formats, or schemes, for displaying data

Programming with Microsoft Visual Basic.NET, Second Edition 47 Summary To access a database from a Visual Basic.NET application, use the DataAdapter, Connection, and DataSet objects Use SQL SELECT to specify the fields and records to view, and to control the order in which the fields and records appear when displayed Use the Fill method to fill a dataset with data while an application is running

Programming with Microsoft Visual Basic.NET, Second Edition 48 Summary (continued) To bind a DataSet object to a DataGrid control –Set DataGrid control’s DataSource property to the name of the DataSet object –Set DataMember property to the name of a table To bind a DataSet object to a list box –Set the list box’s DataSource property to the name of the DataSet object –Set its DisplayMember property to the name of the table and field

Programming with Microsoft Visual Basic.NET, Second Edition 49 Summary (continued) To add a control to a Web form, use the tools on the Web Forms tab in the toolbox To validate user input on a Web page, use one or more Web validator tools To determine whether a postback has occurred, use the Web form’s IsPostBack property To bind a Web DataGrid control to a dataset, use the DataBind method