DT221/3 Internet Application Development Active Server Pages & Database Connection.

Slides:



Advertisements
Similar presentations
Basics of Database Programming with VB6
Advertisements

CIS 375—Web App Dev II ADO I. 2 Introduction ADO (________ Data Objects) is a Microsoft technology for accessing data in a database. ADO is automatically.
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.
Session 6 Server-side programming - ASP. An ASP page is an HTML page interspersed with server-side code. The.ASP extension instead of.HTM denotes server-side.
Prentice Hall © COS 346 Day Agenda Capstone Progress report due Assignment 9 not corrected yet Assignment 10 posted (last one!!!) –Due.
The ADO Data Control. Universal Data Access Open Database Connectivity (ODBC) –standard for accessing data in databases OLE-DB –allows access to data.
Using Visual Basic 6.0 to Create Web-Based Database Applications
 ADO Object Model  Database Connection  Record Set  Query Examples  Update & Insertion Examples  An Application Example Working with Database in.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall COS 346 Day 23.
CVEV 118/698 Active Server Pages Lecture 3 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.
INTERNET DATABASE. Internet and E-commerce Internet – a worldwide collection of interconnected computer network Internet – a worldwide collection of interconnected.
1 Active Server Pages Active Server Pages (ASPs) are Web pages ASP = server-side scripts + HTML The appearance of an Active Server Page depends on who.
Database Connectivity Session 2. Topics Covered ADO Object Model Database Connection Retrieving Records Creating HTML Documents on-the-fly.
CSE 190: Internet E-Commerce Lecture 13: Database code.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
Connecting to Microsoft SQL Server Tuc Goodwin. Introduction We are going to discuss establishing an connection to a SQL Server Database. You will learn.
Client/Server Computing. Information processing is distributed among several workstations and servers on a network, with each function being assigned.
Overview of Database Access in.Net Josh Bowen CIS 764-FS2008.
Microsoft Access Ervin Ha.
IS 4506 Database Connectivity.  Overview Two and Three-Tier C/S Architecture ASP Database Connection ODBC - Connection to DBMS Overview of transaction.
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
FrontPage 2000 Web Page Database Connectivity. Client /Server Architecture Database Server PCs Middleware.
1 Lecture 3 Web Technologies Part 2. 2 l HTML l XHTML l CSS l XML l JavaScript l VBSCRIPT DOM l DHTML l AJAX l E4X l WMLScript l SQL Web Technologies.
ADO.NET – part II August 2004 [ Marmagna Desai]. CONTENTS ADO vs ADO.NET ADO.NET – Managed providers Connecting to Database SqlConnection Selecting Database.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 12-1 David M. Kroenke’s Chapter Twelve: ODBC, OLE DB, ADO, and ASP Part.
Interacting With Data Week 8 Connecting to the database Creating recordsets Interacting with the database.
Interacting With Data Databases.
ADO Connect Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
ActiveX Data Object (ADO) in JavaScript J.L.Wang, Yen-Cheng Chen Dept. of Infomation Management Ming-Chuan University Jan
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
© 2006 ITT Educational Services Inc. Course Name: IT390 Business Database Administration Unit 9 Slide 1 IT 390 Business Database Administration Unit 9:
Data-Enabled Web Sites: Classibooks.com & Internet Database Technologies Colin Fukai April 4, 2000 Gonzaga University.
3/8/00asp00 1 Active Server Pages from Microsoft Nancy McCracken Northeast Parallel Architectures Center at Syracuse.
True or False? Programming languages can be used to update databases and communicate with other systems. True.
Database 20/2/12 Connection. 
Server Side Programming ASP1 Server Side Programming Database Integration (cont.) Internet Systems Design.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Web Services Week 8 Aims: –Using web services as front ends to databases Objectives: –Review of relational databases –Connecting to and querying databases.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
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.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting Tutorial 10.
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.
Introduction to ADO Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Internet Programming ASP Sara Shahzad Dept. of Computer Science UOP.
What is database?  Any Method for access info into Application from DataBase?  ODBC is standard for Accessing Data.  Problem with ODBC:  Information.
How to Connect to Database ODBC (Open Database Connectivity) ADO (ActiveX Data Object) ASP Code To Connect to Database Recordset Object Navigating through.
ActiveX Data Objects (ADO) is Microsoft’s latest database object model. The goal of ADO is to allow VB developers to use a standard set of objects to refer.
Database Management Systems CS 420. Topics Outline 1. Introduction 2. HTML Review 3. VBScript 4. Access DBMS 5. Relational Database 6. Design Process.
Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation.
ASP-12-1 Data Store Access Colorado Technical University IT420 Tim Peterson.
Database Connectivity What is ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a Microsoft Active-X component.
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
ADO.NET Architecture MIS3502: Application Integration and Evaluation David Schuff Adapted from material by Arnold Kurtz, David.
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
SQL Server Microsoft SQL Server 6.5 (startup menu) We’ll use two facilities –Enterprise Manager: to build your db –ISQL_w: to run queries Use this for.
ADO & Recordsets. ADO Description & History  ActiveX Data Objects  History  1991 ODBC  Data Access Objects (DAO) for VB developers (JET)  Remote.
Using databases ActiveX Data Objects (ADO) Connecting to a database Reading data from a database Inserting, updating and deleting records Using databases.
Lecture 4 Manipulating Form Data using methods of Recordset and RecordsetClone in VBA Restrict data with filter 1 Rapid Application Development.
ASP.NET Programming with C# and SQL Server First Edition
Accessing the Database Server: ODBC, OLE DB, and ADO
Working with Database in ASP
ActiveX Data Objects (ADO)
ADO.NET Accessing Databases in VS.NET
Chapter 10 ADO.
Data Access Layer (Con’t) (Overview)
Database Connections.
ASP Database Operations
Presentation transcript:

DT221/3 Internet Application Development Active Server Pages & Database Connection

Outline of ASP Database Connection Active Server Pages can communicate with databases via ADO (ActiveX Data Objects). 1)ADO Object Model 2)Database Connection 3)Record Set 4)Query Example 5)Update & Insertion Example 6)An Application Example

ADO Object Model 1)ADO is a Microsoft technology 2)ADO stands for ActiveX Data Objects 3)ADO is a Microsoft Active-X component 4)ADO is automatically installed with Microsoft IIS 5)ADO is a programming interface to access data in a database 6)ADO can be accessed from within your Active Server Pages

Relationship among the Objects

The normal way to access a database from inside an ASP page is to: 1)Create an ADO connection to a database 2)Open the database connection 3)Create an ADO recordset 4)Open the recordset 5)Extract the data you need from the recordset 6)Close the recordset 7)Close the connection Accessing a Database from an ASP Page

The easiest way to connect to a database is to use a DSN-less connection. A DSN-less connection can be used against any Microsoft SQL database on your web site. If you have a database called "northwind " located in your SQL Server, you can connect to the database with the following ASP code: Database Connection

1)Create a file called “ADOConnection.asp” and type in the code below <% dim connobj dim connstr connstr = "Provider=SQLOLEDB;Data Source=MyServer; Database=Northwind;User Id=NorthUser;Password=abc;" set connobj = Server.CreateObject("ADODB.Connection") connobj.Open (connstr) connobj.Close set connobj = nothing %> 2)The ADO Connection object is used to create an open connection to a data source. Through this connection, you can access and manipulate a database. Database Connection, cont

Create the file “ADORecordset.asp” and type in the code below <% dim connobj dim connstr dim recobj connstr = "Provider=SQLOLEDB;Data Source=MYSERVER;Database=Northwind;User Id=NorthUser;Password=abc;" set connobj = Server.CreateObject("ADODB.Connection") connobj.Open (connstr)'this part create and assign the recordset. set recobj = Server.CreateObject("ADODB.Recordset") 'open the table customer using connobj as the default connection. recobj.Open "Customers", connobj Response.Write("Table Customers opened.") connobj.Close recobj.close set recobj = nothing set connobj = nothing %> Create an ADO Table Recordset

Create a file called “ADORecordset2.asp” and type in the code below: <% dim connobj dim connstr dim recobj connstr = "Provider=SQLOLEDB;Data Source=MYSERVER;Database=Northwind;User Id=NorthUser;Password=abc;" set connobj = Server.CreateObject("ADODB.Connection") connobj.Open (connstr) 'this part create and assign the recordset. set recobj = Server.CreateObject("ADODB.Recordset") 'open the table customer using connobj as the default connection. recobj.Open "Customers", connobj Response.Write("Table Customers opened. ") 'retrieve data Extract Data from the Recordset

for each x in recobj.fields response.write(x.name) response.write(" = ") response.write(x.value & " ") next connobj.Close recobj.Close set recobj = nothing set connobj = nothing %> Extract Data from the Recordset, cont

1)After using the recordset and connection object, it is important to properly close and destroy the objects. 2)Below is the 4 lines necessary to perform such operations. <% Recobj.close Connobj.close Set recobj = nothing Set connobj = nothing %> Closing Recordset and closing Connection

1)ODBC source connection example: Set myDBConnection = Server.CreateObject("ADODB.Connection" ) ConnStr = “DSN=airline db; uid=cis8490; pwd=test” myDBConnection.open connStr 2)OLE connection example Set myDBConnection = Server.CreateObject( "ADODB.Connection " ) myDBConnection.Open “PROVAIDER=SQLOLEDB; DATA SOURCE = yourserver; UID=sa; PWD=secret; DATABASE=Pubs ” 3)ODBC Driver For Trusted Connection security connection example Set myDBConnection = Server.CreateObject("ADODB.Connection " ) myDBConnection.Open "Driver={SQL Server};" & "Server=MyServerName;" & "Database=myDatabaseName;" & "Uid=;" & "Pwd=;" Database Connection Examples