How to Connect to Database ODBC (Open Database Connectivity) ADO (ActiveX Data Object) ASP Code To Connect to Database Recordset Object Navigating through.

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.
Mark Dixon Page 1 17 – Persistent data storage: relational databases and ADO.
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.
ASP Application Development Session 3. Topics Covered Using SQL Statements for: –Inserting a tuple –Deleting a tuple –Updating a tuple Using the RecordSet.
The ADO Data Control. Universal Data Access Open Database Connectivity (ODBC) –standard for accessing data in databases OLE-DB –allows access to data.
ActiveX Data Object ISYS 562. ADO An ActiveX control ActiveX is build upon COM, a contract that defines a standard interface by which objects communicate.
 ADO Object Model  Database Connection  Record Set  Query Examples  Update & Insertion Examples  An Application Example Working with Database in.
CVEV 118/698 Active Server Pages Lecture 3 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.
14 1 Chapter 14 Database Connectivity and Web Development Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
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.
1 C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California
4/8/99 C. Edward Chow Page 1 Active Server Page It is a server-side scripting environment for creating dynamic content. ASP are files with.asp extension,
Database Connectivity Session 2. Topics Covered ADO Object Model Database Connection Retrieving Records Creating HTML Documents on-the-fly.
Visual Basic Database Access BICS546. Microsoft Universal Data Access OLE DB: The OLE database protocol –Allows a program to access information in any.
Connecting a Database to a Web Application Professor Stephen K. Kwan.
Mark Dixon Page 1 18 – Persistent data storage: relational databases and ADO.
4/8/99 C. Edward Chow Page 1 Internet Services Manager Click Start | Programs | Administrative Tools | Internet Services Manager.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
DT221/3 Internet Application Development Active Server Pages & Database Connection.
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
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.
Interacting With Data Week 8 Connecting to the database Creating recordsets Interacting with the database.
Interacting With Data Databases.
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.
ODBC : Open Database Connectivity SNU OOPSLA Lab. October 2005.
Database 20/2/12 Connection. 
Server Side Programming ASP1 Server Side Programming Database Integration (cont.) Internet Systems Design.
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
Fundamentals of Database Chapter 7 Database Technologies.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting Tutorial 10.
Introduction to ADO Y.-H. Chen International College Ming-Chuan University Fall, 2004.
IS 4506 Interactive Clients & Servers.  Overview Fat Client versus Fat Server Spectrum of Web content formats Active Server Pages Active Server Page.
Department of Computer Science 1 Web/Database Integration with Active Server Pages 17 May 2000 Seree Chinodom Computer Science Department.
Lecture Note 10: Simple Database Techniques. Introduction –Database System –Access, SQL Server and others. –Microsoft Access - Interacting with this databases.
What is database?  Any Method for access info into Application from DataBase?  ODBC is standard for Accessing Data.  Problem with ODBC:  Information.
3-Tier Client/Server Internet Example. TIER 1 - User interface and navigation Labeled Tier 1 in the following graphic, this layer comprises the entire.
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.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
1 Web/Database Integration with Active Server Pages 15th/16th October 1998 Nick Gould Faculty of Economic and Social.
CITA 310 Section 7 Installing and Testing a Programming Environment (Textbook Chapter 7)
Open Database Connectivity (ODBC) We’d like more power to manipulate DBs –looping, updating Programs can benefit from using DBs –statistical analysis:
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 What is ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a Microsoft Active-X component.
ASP. ASP is a powerful tool for making dynamic and interactive Web pages An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are.
Database Connectivity and Server-Side Scripting Chapter 12.
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
ODBC : Open Database Connectivity SNU OOPSLA Lab. October 2005.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 6: Accessing a database with PHP Rob Gleasure robgleasure.com.
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
Labtest.ASP Notes. INSERT STATUS INSERT STATUS
1 ADO Activex Data Objects. 2 ADO ADO allows users to access data easily from many existing databases (such as Access or Paradox) From ODBC compliant.
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.
Generating XML Data from a Database Eugenia Fernandez IUPUI.
 2 Data Object Library approaches ◦ DAO (Data Access Objects)  Original access strategy (up to VB6)  Closely linked to MS Access ◦ ADO (ActiveX Data.
Visual Basic Database Access
Accessing the Database Server: ODBC, OLE DB, and ADO
Working with Database in ASP
VISUAL BASIC INTRODUCTION TO DATA CONNECTIVITY.
Chapter 10 ASP and Data Store Access
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Chapter 10 ADO.
Database Connections.
ASP Database Operations
Presentation transcript:

How to Connect to Database ODBC (Open Database Connectivity) ADO (ActiveX Data Object) ASP Code To Connect to Database Recordset Object Navigating through Recordset

ODBC Stands for Open Database Connectivity Is a standard database access method developed by the SQL Access group in 1992 Has the goal of making it possible to access any data from any application, regardless of DBMS being used Uses a middle layer called a driver between the application (e.g., SQL program) and the DBMS (e.g., MS Access)

ODBC SQL Applications (Programs) ODBC Driver Manager (provided by MS) ODBC drivers for specific DB (provided by specific vendor) SQL DBMS or Access DBMS

ADO Stands for ActiveX Data Objects Is a high-level interface for accessing data objects—way of looking at data objects (developed by Microsoft) What is ADO’s relationship to ASP? o ASP code can manipulate ADO objects, using VBScript sintax Sample code o See later slides

ADO on the Web Server BrowserServer ASP Engine ADO Objects 1.Browser requests ASP page from Server 2.Server sends ASP page to ASP Engine 3.ASP Engine executes Server-side scripts 4.ASP Engine calls ADO objects (if any) 5.ADO objects do their thing 6.ASP Engine returns HTML to Server 7. Server returns HTML to Browser

ADO & COM ADO (ActiveX Data Objects) objects are COM (Component Object Model) objects specifically designed to interact with ODBC objects. The purpose of ADO objects is to gain access to database through ASP ODBC (Open Database Connectivity) -- standard database access method developed by MS --Access, dBase4, Paradox, FoxPro, etc.

ADO Objects Command o to give command to a database Connection o link between ASP application and the database RecordSet o will be used most often o container for a “Cursor”, a temporary table

To Access Database from ASP Page 1.Form an SQL statement. 2.Create and Open ADO connection to the database. 3.Create and Open ADO recordset object. 4.Extract data from the recordset 5.Close recordset object 6.Close connection object

To Form SQL Statement <% ' Form SQL String Dim strSQL strSQL="" strSQL=strSQL & " SELECT firstName, lastName " strSQL=strSQL & " FROM Customers “ %>

To Connect to Database // Assume that strSQL contains SQL statement to be // executed. Dim conn, recSet Set conn=Server.CreateObject(“ADODB.Connection”) conn.Provider=”Microsoft.Jet.OLEDB.4.0” conn.Open Server.MapPath(“mydatabase.mdb”) Set recSet = Server.CreateObject("ADODB.Recordset") conn.Open strSQL conn

ASP Code to Connect to Database (Alternate) // Assume that strSQL contains SQL statement to be // executed. Dim DBSource, conn, recSet DBSource = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ Server.MapPath("dealer.mdb") Set conn = Server.CreateObject("ADODB.Connection") Set recSet = Server.CreateObject("ADODB.Recordset") conn.Open DBSource ' Execute SQL recSet.Open strSQL, conn, 1, 1

Connecting to DB (Alternate) 1.Create SQL Statement strSQL=“SELECT firstName, lastName FROM Customers” 2.Connect to Physicsl DB DBSource = "Provider=Microsoft.Jet.OLEDB.4.0; _ Data Source=" & Server.MapPath("dealer.mdb") oCreate Connection Object Set conn = Server.CreateObject("ADODB.Connection") Create RecordSet object Set recSet = CreateObject(“ADODB.RecordSet”) Open the RecordSet recSet.Open strSQL, conn, 1, 1

Complete Code for Connecting to Database <% Dim conn, recSet, strSQL ' Form SQL String strSQL="" strSQL=strSQL & " SELECT firstName, lastName " strSQL=strSQL & " FROM Customers " ' Open database connection Set conn=Server.CreateObject(“ADODB.Connection”) conn.Provider=”Microsoft.Jet.OLEDB.4.0” conn.Open Server.MapPath(“mydatabase.mdb”) Set recSet = Server.CreateObject("ADODB.Recordset") conn.Open strSQL conn %>

RecordSet Current Record Pointer

Navigating through a RecordSet If recSet.EOF and recSet.BOF Then ‘ no records Response.Write(“No matching records found”) Else Do While Not recSet.EOF val1 = recSet(“firstName”) val2 = recSet(“firstName”) Reponse.Write(val1 & “ “ val2 & “ ”) recSet.MoveNext Loop End If

Complete Code <% Dim strSQL strSQL="" strSQL=strSQL & " SELECT firstName, lastName " strSQL=strSQL & " FROM Customers " ' Open database connection Set conn=Server.CreateObject(“ADODB.Connection”) conn.Provider=”Microsoft.Jet.OLEDB.4.0” conn.Open Server.MapPath(“mydatabase.mdb”) Set recSet=Server.CreateObject(“ADODB.Recordset”) conn.Open strSQL, conn %>

All Customers All Customers <% Do While not recSet.eof Response.Write(recSet(“firstName") & " " & _ recSet("nameLast") & " " ) recSet.MoveNext loop recSet.close Set recSet = Nothing conn.close Set conn = Nothing %>

RecordSet Properties BOF o beginning of a recordset EOF o end of a recordset RecordCount o number of records

RecordSet Methods AddNew o Add new record to the record set Close o Close the recordset Delete o Delete the current record MoveNext o Move record pointer to the next record Open o Open the recordset (execute the query)