Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.

Slides:



Advertisements
Similar presentations
Chapter 10 ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a programming interface to access data in a database.
Advertisements

Chapter 12: Using ADO.NET 2.0 Programming with Microsoft Visual Basic 2005, Third Edition.
Introduction to Database Processing with ADO.NET.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-1 COS 346 Day 25.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Object-Oriented Application Development Using VB.NET 1 Chapter 13 Introduction to Data Access Classes and Persistence.
14 1 Chapter 14 Database Connectivity and Web Development Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 14: Advanced Topics: DBMS, SQL, and ASP.NET
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Objective In this session we will discuss about : What is ADO. NET ?
Overview of Database Access in.Net Josh Bowen CIS 764-FS2008.
Page 1 ISMT E-120 Introduction to Microsoft Access & Relational Databases The Influence of Software and Hardware Technologies on Business Productivity.
CIS 764 – Presentation Somil Chandwani.  With Microsoft Data Access Components (MDAC), developers can connect to and use data from a wide variety of.
Chapter 8 Binding Data to Web Controls. ASP.NET 2.0, Third Edition2.
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.
Intro to JDBC To effectively use Java Data Base Connectivity we must understand: 1.Relational Database Management Systems (RDBMS) 2.JDBC Drivers 3.SQL.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Chapter 61 Managing Data Sources Introduction to ASP.NET By Kathleen Kalata.
1 Overview of Databases. 2 Content Databases Example: Access Structure Query language (SQL)
ADO.NET A2 Teacher Up skilling LECTURE 3. What’s to come today? ADO.NET What is ADO.NET? ADO.NET Objects SqlConnection SqlCommand SqlDataReader DataSet.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
1 ASP.NET ASP.NET Rina Zviel-Girshin Lecture 4. 2 Overview Data Binding Data Providers Data Connection Data Manipulations.
Web Services Week 8 Aims: –Using web services as front ends to databases Objectives: –Review of relational databases –Connecting to and querying databases.
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
Databases and Data Access  Introduction to ADO.NET  ADO.NET objects  ADP.NET namespaces  Differences between ADO and ADO.NET.
CHAPTER EIGHT Accessing Data Processing Databases.
CHAPTER EIGHT Accessing Data Processing Databases.
Chapter 3 Introduction to ADO.NET 3.1 The ADO and ADO.NET ActiveX Data Object (ADO) is developed based on Object Linking and Embedding (OLE) and Component.
File Processing Concepts – Field – combination of 1 or more characters that is the smallest unit of data to be accessed – Record – group of related fields.
Relational Databases Database Driven Applications Retrieving Data Changing Data Analysing Data What is a DBMS An application that holds the data manages.
 It is the primary data access model for.Net applications  Next version of ADO  Can be divided into two parts ◦ Providers ◦ DataSets  Resides in System.Data.
Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET.
Module 9: Accessing Relational Data Using Microsoft Visual Studio.NET.
Module 7: Accessing Data by Using ADO.NET
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
Presented by Joseph J. Sarna Jr. JJS Systems, LLC
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
 It is the primary data access model for.Net applications  Next version of ADO  Can be divided into two parts ◦ Providers ◦ DataSets  Resides in System.Data.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Introduction to ADO.Net and VS Database Tools and Data Binding ISYS 350.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 25.1 Test-Driving the ATM Application 25.2.
BlackBerry Applications using Microsoft Visual Studio and Database Handling.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 22 - SQL, MySQL, DBI and ADO Outline 22.1 Introduction 22.2 Relational Database Model 22.3 Relational.
Databases and ADO.NET Programming Right from the Start with Visual Basic.NET 1/e 11.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
Module 4 Introduction ADO.NET.
Introduction Because database applications today reside in a complicated environment, various standards have been developed for accessing database servers.
Data Access. ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB.
ADO .NET from. ADO .NET from “ADO .Net” Evolution/History of ADO.NET MICROSOFT .NET “ADO .Net” Evolution/History of ADO.NET History: Most applications.
.NET Data Access and Manipulation
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
Introduction to Database Programming with Python Gary Stewart
Integrating Data Lesson 6.
ASP.NET Programming with C# and SQL Server First Edition
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
ADO.NET Framework.
Programming the Web Using ASP.Net
Chapter 8 Working with Databases and MySQL
Chapter 10 ADO.
Presentation transcript:

Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition

2 Objectives Study databases Connect to databases with ASP.NET Execute SQL commands through ASP.NET

JavaScript, Third Edition 3 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting languages, including ASP.NET: –Have the ability to create Web pages that can read and write data to and from databases

JavaScript, Third Edition 4 Understanding Databases Database: –Ordered collection of information from which a computer program can quickly access information The information stored in computer databases is stored in tables

JavaScript, Third Edition 5 Understanding Databases (Cont.) Each row in a database table is called a record: –Single complete set of related information Each column in a database table is called a field: –Individual categories of information stored in a record

JavaScript, Third Edition 6 Understanding Databases (Cont.)

JavaScript, Third Edition 7 Understanding Databases (Cont.) A better solution for large and complex databases is a relational database A relational database stores information across multiple related tables

JavaScript, Third Edition 8 Understanding Databases (Cont.) Relational databases consist of one or more related tables You create relationships within the database: –By working with two tables at a time One table in a relationship is always considered to be the primary table –The other table is considered to be the related table

JavaScript, Third Edition 9 Understanding Databases (Cont.) Primary table: –Main table in a relationship referenced by another table Related table (child table): –References a primary table in a relational database Tables in a relationship are connected using primary and foreign keys

JavaScript, Third Edition 10 Understanding Databases (Cont.) Primary key: –Field that contains a unique identifier for each record in a primary table Foreign key: –Field in a related table that refers to the primary key in a primary table Primary and foreign keys link records across multiple tables in a relational database

JavaScript, Third Edition 11 Understanding Databases (Cont.)

JavaScript, Third Edition 12 Understanding Databases (Cont.) Three basic types of relationships within a relational database: –one-to-one –one-to-many –many-to-many A one-to-one relationship: –Exists between two tables when a related table contains exactly one record for each record in the primary table

JavaScript, Third Edition 13 Understanding Databases (Cont.) A one-to-many relationship: –Exists in a relational database when one record in a primary table has many related records in a related table You create a one-to-many relationship in order to eliminate redundant information in a single table

JavaScript, Third Edition 14 Understanding Databases (Cont.)

JavaScript, Third Edition 15 Understanding Databases (Cont.)

JavaScript, Third Edition 16 Understanding Databases (Cont.) Primary and foreign keys: –The only pieces of information in a relational database table that should be duplicated Normalization: –Breaking tables into multiple related tables in order to reduce redundant and duplicate information –Reduces the size of a database Makes the data easier to work with

JavaScript, Third Edition 17 Understanding Databases (Cont.) A many-to-many relationship: –Exists in a relational database when many records in one table are related to many records in another table To create a many-to-many relationship: – You must use a junction table Most relational database systems cannot work directly with many-to-many relationships

JavaScript, Third Edition 18 Understanding Databases (Cont.) A junction table: –Creates a one-to-many relationship for each of the two tables in a many-to-many relationship –Contains foreign keys from the two tables in a many- to-many relationship, along with any other fields that correspond to a many-to-many relationship

JavaScript, Third Edition 19 Understanding Databases (Cont.)

JavaScript, Third Edition 20 Database Management Systems A database management system (DBMS): –An application or collection of applications used to create, access, and manage a database –Runs on many different platforms, ranging from personal computers, to client-server systems, to mainframes

JavaScript, Third Edition 21 Database Management Systems (Cont.) Different database management systems exist: –A flat-file database management system –A relational database management system, or RDBMS –Hierarchical and network database management systems –Oracle, Sybase, and Informix –Access, FoxPro, and Paradox

JavaScript, Third Edition 22 Database Management Systems (Cont.) Two other important aspects of database management systems are: –Their querying and reporting capabilities A query: –A structured set of instructions and criteria for retrieving, adding, modifying, and deleting database information

JavaScript, Third Edition 23 Database Management Systems (Cont.) A report: –The formatted, printed output of a database table OR – The results of a query Most database management systems use a data manipulation language, or DML: –ex: structured query language, or SQL (pronounced sequel)

JavaScript, Third Edition 24 Database Management Systems (Cont.)

JavaScript, Third Edition 25 Database Management Systems (Cont.)

JavaScript, Third Edition 26 Structured Query Language SQL uses fairly easy-to-understand statements to execute database commands SQL statements are composed of keywords that perform actions on a database

JavaScript, Third Edition 27 Structured Query Language (Cont.)

JavaScript, Third Edition 28 Connecting to Databases with ASP.NET With Active Server Pages, you use ActiveX Data Objects to access databases ActiveX Data Objects, or ADO: –A Microsoft database connectivity technology –Allows ASP and other Web development tools to access ODBC- and OLE DB-compliant databases OLE DB: –A data source connectivity standard promoted by Microsoft as a successor to ODBC

JavaScript, Third Edition 29 Connecting to Databases with ASP.NET (Cont) One of the primary differences between OLE DB and ODBC is: –ODBC supports access only to relational databases –OLE DB provides access to both relational databases and non-relational data sources ADO.NET: –Most recent version of ADO –Allows you to access OLE DB-compliant data sources and XML –Use to directly access Microsoft SQL Server databases, without having to go through OLE DB

JavaScript, Third Edition 30 Connecting to Databases with ASP.NET (Cont) ADO and OLE DB: –Part of Microsoft Universal Data Access strategy for providing access to data, regardless of its storage format MDAC Or Microsoft Data Access Components : –Make up the Universal Data Access technology –Installed with numerous Microsoft products, including Internet Explorer, Internet Information Server, Microsoft Visual Studio, and the Microsoft.NET Framework SDK

JavaScript, Third Edition 31 ADO.NET Object Model ADO.NET technology: –Based on an object model used for accessing and manipulating data sources

JavaScript, Third Edition 32 ADO.NET Object Model (Cont) Import processing directive –Used to import a namespace in order for the ASP.NET documents to access the ADO.NET object model Namespaces: –Used for managing the various classes and other elements in the.NET Framework

JavaScript, Third Edition 33 ADO.NET Object Model (Cont) There are numerous namespaces available to the.NET Framework: –Many are imported automatically into your ASP.NET programs –Others, including namespaces that give ASP.NET access to database connectivity classes, must be explicitly imported

JavaScript, Third Edition 34 ADO.NET Object Model (Cont) To access the OLE DB namespace: –You must import the System.Data.OleDb namespace –This is done by adding the following statement to your ASP.NET documents:

JavaScript, Third Edition 35 The ADO.NET Connection Object Connection object: –Used to access databases from ASP.NET ADO.NET includes two Connection objects: –The SqlConnection object Connects to Microsoft SQL Server version 7.0 or later –The OleDbConnection object Connects to OLE DB data sources

JavaScript, Third Edition 36 The ADO.NET Connection Object (Cont)

JavaScript, Third Edition 37 The ADO.NET Connection Object (Cont)

JavaScript, Third Edition 38 The ADO.NET Connection Object (Cont) First step in working with a database in ASP.NET: –Create an instance of the OleDbConnection object using the following syntax: Var object = new OleDbConnection("connection string”); Connection string must include the Provider and DataSource name=value pairs You assign to Provider the name of the.NET data provider: –Identifies the relational database system you want to access

JavaScript, Third Edition 39 The ADO.NET Connection Object (Cont)

JavaScript, Third Edition 40 Opening and Closing a Data Source You must use the Open() method to open a specific data source Use the Close() method to disconnect the database connection –Necessary because database connections do not close automatically when an ASP.NET program ends

JavaScript, Third Edition 41 Checking the Database Connection The State property contains a string indicating the current status of the database connection

JavaScript, Third Edition 42 Executing SQL Commands Through ASP.NET ADO.NET provides four primary objects for accessing and manipulating data sources: –Command object –DataReader object –DataSet object –DataAdapter object

JavaScript, Third Edition 43 The Command Object The Command object: –Executes a command, such as an SQL command, against a data source –ADO.NET includes two Connection objects: SqlCommand object: executes commands against Microsoft SQL Server version 7.0 or later OleDbCommand object: executes commands against an OLE DB data source

JavaScript, Third Edition 44 The DataReader Object A DataReader object: –Retrieves read-only, forward-only data from a data source ADO.NET includes two DataReader objects: –SqlDataReader object: retrieves data from Microsoft SQL Server version 7.0 or later –OleDbDataReader object: retrieves data from OLE DB data sources You use the ExecuteReader() method of the OleDbCommand object to create an OleDbDataReader object

JavaScript, Third Edition 45 The DataReader Object (Cont) The OleDbDataReader object contains various properties and methods for reading the returned data Read() method: –Advances the leDbDataReader object to the next record Cursor: –The position within the record set

JavaScript, Third Edition 46 Chapter Summary A database: –An ordered collection of information from which a computer program can quickly access information A record in a database: –Contains a single, complete set of related information Fields: –The individual categories of information stored in a record

JavaScript, Third Edition 47 Chapter Summary (cont.) A flat-file database: –Stores information in a single table A relational database: –Stores information across multiple related tables A primary table: –The main table in a relationship referenced by another table A related table (also called a child table): –References a primary table in a relational database

JavaScript, Third Edition 48 Chapter Summary (cont.) A primary key: –A field that contains a unique identifier for each record in a primary table A foreign key: –A field in a related table that refers to the primary key in a primary table A one-to-one relationship: –Exists between two tables when a related table contains exactly one record for each record in the primary table

JavaScript, Third Edition 49 Chapter Summary (cont.) Normalization: –Breaking tables into multiple related tables in order to reduce redundant and duplicate information A many-to-many relationship: –Exists in a relational database when many records in one table are related to many records in another table A database management system (DBMS): –An application or collection of applications used to create, access, and manage a database

JavaScript, Third Edition 50 Chapter Summary (cont.) ActiveX Data Objects, or ADO: –A Microsoft database connectivity technology that allows ASP and other Web development tools to access ODBC- and OLE DB-compliant databases A one-to-many relationship: –Exists in a relational database when one record in a primary table has many related records in a related table

JavaScript, Third Edition 51 Chapter Summary (cont.) ADO.NET includes two Connection objects: –The SqlConnection object –The OleDbConnection object The Command object: –Executes a command, such as a SQL command, against a data source ADO.NET includes two Command objects: –The SqlCommand object –The OleDbCommand object

JavaScript, Third Edition 52 Chapter Summary (cont.) A DataReader object: –Retrieves read-only and forward-only data from a data source ADO.NET includes two DataReader objects: –The SqlDataReader object and the OleDbDataReader object: retrieves data from OLE DB data sources