Dynamic Web Sites DECO 3001 Tutorial 6 – Form Presented by Ji Soo Yoon 30 April 2004 Slides adopted from

Slides:



Advertisements
Similar presentations
Basics of Database Programming with VB6
Advertisements

Developing Database-resident Help for Customizable Web-based Applications Scott DeLoach.
E-Commerce CMM503 – Lecture 8 Stuart Watt Room C2.
Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
Building Applications using ASP.NET and C# / Session 1 / 1 of 21 Session 1.
1 Chapter 12 Working With Access 2000 on the Internet.
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.
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.
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.
Visual Basic Database Access BICS546. Microsoft Universal Data Access OLE DB: The OLE database protocol –Allows a program to access information in any.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
Beyond DHTML So far we have seen and used: CGI programs (using Perl ) and SSI on server side Java Script, VB Script, CSS and DOM on client side. For some.
Interacting With Data Databases.
4-1 INTERNET DATABASE CONNECTOR Colorado Technical University IT420 Tim Peterson.
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.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 33 - Active Server Pages (ASP) Outline 33.1 Introduction 33.2 How Active Server Pages Work 33.3.
Introduction to ADO By David R. Stevenson Consulting Software Engineer ABB Automation.
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.
Server Side Programming ASP1 Server Side Programming Database Integration (cont.) Internet Systems Design.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting Tutorial 10.
ASP/ASP.NET: Tricks and Tips How to get Microsoft’s Programming Language to work for you By Wade Tripp Park University
Department of Computer Science 1 Web/Database Integration with Active Server Pages 17 May 2000 Seree Chinodom Computer Science Department.
Website Development with PHP and MySQL Saving Data.
Lecture Note 10: Simple Database Techniques. Introduction –Database System –Access, SQL Server and others. –Microsoft Access - Interacting with this databases.
Visual Basic ADO Programming 56:150 Information System Design.
Chapter 6 Server-side Programming: Java Servlets
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
What’s new in ADO 2.5 Greg Hinkel Program Manager Data Access Group
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.
Lecture Note 8: ASP Including Files and The Global.asa file.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
1 Web/Database Integration with Active Server Pages 15th/16th October 1998 Nick Gould Faculty of Economic and Social.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP (COMPONENTS) Active Server Pages (cont..) 1. global.asa file The Global.asa file is an optional file that can contain declarations of objects, variables,
Database Connectivity and Server-Side Scripting Chapter 12.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Source = Table rsObject.Open tablename, Connection Object, CursorType, LockType, adCmdTable Source = Stored Procedure rsObject.Open stored procedure name,
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.
ASP-13-1 Recordsets Colorado Technical University IT420 Tim Peterson.
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.
Using databases ActiveX Data Objects (ADO) Connecting to a database Reading data from a database Inserting, updating and deleting records Using databases.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
 2 Data Object Library approaches ◦ DAO (Data Access Objects)  Original access strategy (up to VB6)  Closely linked to MS Access ◦ ADO (ActiveX Data.
ASP – Web Programming Class  Ravi Anand. ASP – Active Server Pages What is ASP? - Microsoft Technology - Can Run using IIS/PWS/Others - Helps us create.
Visual Basic Database Access
Chapter 33 - Active Server Pages (ASP)
ASP Explained By: Sarbjit Kaur.
INT213 Updating the Database.
Active Server Pages ASP.Net
PHP / MySQL Introduction
The Request & Response object
ASP.
Browser and Server Models
Presentation transcript:

Dynamic Web Sites DECO 3001 Tutorial 6 – Form Presented by Ji Soo Yoon 30 April 2004 Slides adopted from and A Practical Guide To Active Server Pages 3.0 ©2000 Manas Tungarehttp://aurora.wells.edu/~ccs/cs310/02/cs310.htm

Active Server Pages Revisited An Active Server Page is a text script with extension.asp An ASP typically contains HTML, client and server scripts  ASP code is bracketed in  Pre-processed (like SSIs) before the page is sent to the client  Statements in VBScript (similar to VB) or in JavaScript  Uses built-in ASP objects  Uses prewritten active server components (called COM objects stored in.dll or.exe files)  Can build new COM objects (harder)

“Hello World” Example <% Dim I ' declare our loop index variable %> <% For I = 1 To 5 Step 1 %> ” >Hello World <% Next ' bounce back to the top of the loop %>

Advantages Easier to code Faster execution with multiple hits  Each CGI program loads separate code  Two ASP pages can use the same.dll file which is loaded only once Expected availability of Microsoft and third party COM objects  Can be developed in (almost) any language Fostered by Microsoft

Disadvantages Evolving rapidly Hard to gain detailed information of different components Fostered by Microsoft

Intrinsic Objects ASP programs have access to intrinsic objects  Request  Response  Application  Session  Server Each of the objects has a set of collections, methods, properties and events which provide them with all their functionality

Request Object Information returned with the HTTP header (GET) or body (POST) Properties  TotalBytes (the size of data in HTTP header) Collections  ClientCertificate (for security)  Cookies  Form  QueryString  ServerVariables

Request.QueryString The information sent using GET Request.QueryString is everything after the ? Request.QueryString("name")  Gets value for  If this is from a form, it will be associated with an input box with NAME= name

Request.Form The information sent from a form via POST Request.Form(“name”) gets the value assigned to an input box with NAME= name

Request.ServerVariables Environment variables in HTTP header CGI equivalent: environment variables  See 2.cgi

Response Object Control over information sent to the client in the HTTP response: when, how, what Properties  Buffer, CacheControl, Charset, ContentType, Expires,... Collections  Cookies Methods  AddToHeader, AppendToLog, Clear, End, Flush, Redirect  Write (most frequently-used)

Other Intrinsic Objects Application  An application is all files that can be accessed through a directory and its subdirectories  Allows variables and objects with application-level scope  Application_OnStart event when first client requests a file Session  Tracks the current user’s info, Initialized via Session_OnStart Server  Properties: ScriptTimeout  Methods: CreateObject, HTMLEncode, MapPath, URLEncode Server.ScriptTimeout = 100 Server.CreateObject(“ADODB.Connection”))

Installable Components ASP programs have access to intrinsic objects (Request, Response, Application, Session, Server) Other objects can be “installed”  Standard library  Built for a particular application COM is the interface standard for these objects which have methods and properties Examples:  Collaboration Data Objects: CDONTS  ActiveX Data Objects: ADODB  Others: Ad Rotator, Content Linking, Content Rotator, Counters, File Access, Page Counter, Permission Checker

Collaboration Data Objects (CDO) CDO adds messaging functions to applications. CDONTS is a COM library for NT designed to send mail through SMTP To create the CDONTS object Dim objCDOMail 'The CDO object Set objCDOMail = Server.CreateObject("CDONTS.NewMail") This has Attributes: From, To, Subject, Body, Cc, Bcc, AttachFile,... Method: Send Procedure:  assign values to the attributes  apply Send

Sending a simple message Dim objCDOMail Set objCDOMail = Server.CreateObject("CDONTS.NewMail") objCDOMail.To = “Receiver Address” objCDOMail.From = “Sender Address” objCDOMail.Subject = “Subject” objCDOMail.Body = “Body” objCDOMail.Send Set objCDOMail = Nothing

File Access Access to a file system via the FileSystemObject  Server.CreateObject(“Scripting.FileSystemObjec t”) File system has folders, drives, files Methods: CreateFolder, CreateTextFile, DriveExists, DeleteFile, GetFile, OpenTextFile,... Text file methods: Read, ReadLine, Write,

ADO: Active Data Objects ADODB.Connection: to a data provider (db) ADODB.Recordset: the records returned from a query (or a whole table) ADODB.Field: a component in a recordset ADODB.Command: an SQL statement that returns a recordset ADODB.Parameter: holds parameters in an SQL statement ADODB.Error, ADODB.Property

Connection Object A connection to the database. Can be used for more than one query. Properties  ConectionTimeout  CommandTimeout  ConnectionString Methods  Open  Close

Example Set DataConn = Server.CreateObject("ADODB.Connection") DataConn.ConnectionTimeout = 15 'property DataConn.CommandTimeout = 30 ‘property Note, this has no connection to any data yet. DataConn.Open "DBQ=" & Server.MapPath("database.mdb") & ";Driver={Microsoft Access Driver (*.mdb)}; DriverId=25; MaxBufferSize=8192; Threads=20;", "username", "password" An Access database, database.mdb on the default directory Fill in correct “username” and” password”

Recordset Object Records in a query or table from the connection It must be opened to have anything in it Properties  ActiveConnection: the current data source  Fields: in the table  BOF, EOF: of the recordset Methods  AddNew  Delete  MoveFirst, MoveNext, MoveLast  Open, Close

Command Object Not necessary (one can just type in when a recordset is opened), but a neat way to define and reuse commands Properties  CommandText  CommandType (adcmdText = SQL, adcmdTable = table name, Methods  Execute

File Access Access to a file system via the FileSystemObject  Server.CreateObject(“Scripting.FileSystemObjec t”) File system has folders, drives, files Methods: CreateFolder, CreateTextFile, DriveExists, DeleteFile, GetFile, OpenTextFile,... Text file methods: Read, ReadLine, Write,

More ADODB Major objects: Connection and Recordset Possible interfaces to a database  via a connection – previous slides  directly – slides to come Recordset Connection Recordset DB Recordset

Comparison Connection  Cleaner  Allows multiple recordsets without recreating and duplicating the connection  Easier to change in one place Just recordset  Less code to write (not a good reason)

Using a connection Set DataConn =Server.CreateObject("ADODB.Connection") strConnString = "DRIVER={Microsoft Access Driver... DataConn.Open strConnString, strUserId, strPasswd Set rsObj = Server.CreateObject("ADODB.Recordset") cmdSQL = “SELECT…” rsObj.Open cmdSQL, DataConn, CursorType, LockType,.. The first param is an SQL statement, a table, procedure name The second param is a connection object or string with connection text

Using a recordset: With intermediate variables: strConnString = "DRIVER={Microsoft Access... Set rsObj= Server.CreateObject("ADODB.Recordset") rsObj.Open cmdSQL, strConnString, … More confusing, put everything in the Open command: rsObj.Open “SELECT…”, "DRIVER={Microsoft Access…”, …

ASP Components Components (e.g. ADODB) have classes  e.g. Connection, Recordset, Field, Command,.. Classes have methods  e.g. Open, Close,.. The ADODB.dll is available to ASP pages and supports this component An object is created in an ASP page with the create method of Server  Server.CreateObject(“component_name.class_name”)  objDataConn =Server.CreateObject(“ADODB.Connection”) The object then has access to the methods of the class

Developing components Most easily built in VB. Ref: Shelly Powers. Open VB Select File/New Project/ActiveX DLL You get Project1 and a Class1 window Change Project1 name to NewCom in Project/Properties Change Class1 name to CLA in the window for Class 1 Build functions for AddNew, Remove, … in the (Code) window Public Function AddNew() End Function Make/Project creates NewCom.dll regsvr32 NewCom.dll registers it objCLA = Server.CreateObject(“NewCOM.CLA”) creates an instance

ASP Learning and Code Sites ASP Lessons  ASP Tutorial  ASP Tips  ADO Connection String Samples  Microsoft’s ASP Site  Other ASP Sites 