Presentation is loading. Please wait.

Presentation is loading. Please wait.

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall COS 346 Day 23.

Similar presentations


Presentation on theme: "DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall COS 346 Day 23."— Presentation transcript:

1 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall COS 346 Day 23

2 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall Agenda Questions? Quiz 3 is Today –DP Chap 9 & 11, SQL Chap 11 Quiz 4 is on May 4 –DP Chap 12 – 15 –Password is “ConCurrency” Next Capstone progress report Due April 24 Assignment 9 is posted –Due April 24 –More detailed instructions on 12.53 have been provided Capstones projects and presentations are due May 12 at 10AM Today we will be discussing ADO and ASP

3 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall David M. Kroenke’s Chapter Twelve: ODBC, OLE DB, ADO, and ASP Part Two Database Processing: Fundamentals, Design, and Implementation

4 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall Active Data Objects (ADO) Active Data Objects (ADO) characteristics: –A simple object model for OLE DB data consumers –It can be used from VBScript, JScript, Visual Basic, Java, C#, C++ –It is a single Microsoft data access standard –Data access objects are the same for all types of OLE DB data

5 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall Invoking ADO from Active Server Pages In Microsoft’s Active Server Pages (ASP) are Web pages where: –Statements are enclosed within the characters.and processes on the WEB Server –ASP statements are processed on the Web server. (not all) –Other (HTML) statements are processed by the client Web browser.

6 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall The ADO Object Model

7 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall Connection Object A connection object establishes a connection to a data provider and data source. –Connections have an isolation mode. Once a connection is created, it can be used to create RecordSet and Command objects.

8 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall RecordSet Objects RecordSet objects represent cursors: –They have both CursorType and LockType properties. –RecordSets can be created with SQL statements. –The Fields collection of a RecordSet can be processed to individually manipulate fields. –The Errors collection contains one or more error messages that result from an ADO operation.

9 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall Command Object The command object is used to execute stored parameterized queries or stored procedures: –Input data can be sent to the correct ASP using the HTML FORM tag. –Table updates are made using the RecordSet Update method.

10 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall ADO Constants: Isolation Levels

11 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall ADO Constants: Cursor Levels

12 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall ADO Constants: Lock Types

13 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall Connection Object: ASP Code <% Dim objConn Set objConn = Server.CreateObject (“ADODB.connection”) objConn.IsolationLevel = adXactReadCommitted ‘ use ADOVBS objConn.Open “ViewRidgeSS”, %> <% objConn.Open “DSN=ViewRidgeOracle2;UID=DK1;PWD=Sesame” %>

14 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall RecordSet Object: ASP Code <% Dim objRecordSet, varSql varSQL = “SELECT * FROM ARTIST” Set objRecordSet = Server.CreateObject(“ADODB.Recordset”) objRecordSet.CursorTye = adOpenStatic objRecordSet.LockType = adLockReadOnly objRecordSet.Open varSQL, objConn %>

15 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall Fields Collection: ASP Code <% Dim varI, varNumCols, objField varNumCols = objRecordSet.Fields.Count For varI = 0 to varNumCols - 1 Set objField = objRecordSet.Fields(varI) ‘ objField.Name now has the name of the field ‘ objField.Value now has the value of the field ‘ can do something with them here Next >%

16 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall Errors Collection: ASP Code <% Dim varI, varErrorCount, objError On Error Resume Next varErrorCount = objConn.Errors.Count If varErrorCount > 0 Then For varI = 0 to varErrorCount - 1 Set objError = objConn.Errors(varI) ‘ objError.Description contains ‘ a description of the error Next End If >%

17 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall Command Object: ASP Code <% Dim objCommand, objParam, objRs ‘Create the Command object, connect it to objConn and set its format Set objCommand = Server.CreateObject(“ADODB.command”) Set objCommand.ActiveConnection = objConn objCommand.CommandText=“{call FindArtist (?)}” ‘Set up the parameter with the necessary value Set objParam = objCommand.CreateParameter (“Nationality”, adChar, adParamInput, 25) objCommand.Parameters.Append objParam objParam.Value = “Spanish” ‘Fire the Stored Proc Set objRs = objCommand.Execute >%

18 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall ADO Example: Reading a Table Artist.asp artist.asp

19 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall ADO Example: Reading a Table The Artist.asp Results

20 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall

21 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 12.53 Read the customer table results from Figure 12-18 using MSSQL instead of Oracleresults from Figure 12-18 Steps –Create SQL Login for the ASP page and the OBDC connector Set the right permissions to the right objects –Create OBDC connector –Create web directory on your desktop Copy the “adovbs.inc” file to the directory Modify and place the *.asp file in the directory –Run the page the local web server. –Provide a screen dump to show that you did accomplish the objective before and after deleting two rows (delete the last two rows)

22 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall David M. Kroenke’s Database Processing Fundamentals, Design, and Implementation (10 th Edition) End of Presentation: Chapter Twelve Part Two


Download ppt "DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall COS 346 Day 23."

Similar presentations


Ads by Google