Download Data Access Using Active Server Page (ASP)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Entity–attribute–value model wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Database wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Relational model wikipedia , lookup

Microsoft Access wikipedia , lookup

Functional Database Model wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

Transcript
ECMM 6010: TERM PAPER PRESENTATION
Data Access Using
Active Server Page (ASP)
Sagar Thulung
(B00349076)
MEC Candidate
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Table of content
•
•
•
•
•
ASP Introduction
Requirement
Basic of ASP coding
Introduction to some of the ASP objects
Accessing data store
– Connecting string
– Connecting to database
– Executing queries
– Using Recordset object to manipulate results
• Managing database connection
• Summary
• References
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
ASP introduction
• ASP is a text file with extension .asp that contains combination of
the following:
– text;
– HTML tags; and,
– ASP script commands
• ASP is a server-side scripting environment that helps us to create
and run dynamic, interactive web server applications.
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Requirement
•
•
•
•
Text editor (notepad, Visual InterDev, …)
Browser
Server (PWS, IIS)
Limitation:
Others
– DBMS
– Image editing tools
– …
- Limited to MS Win based platform
- PWS:
-Runs in Win 9X only
-About 20 concurrent users only
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Basic of ASP coding
• Enclosed between delimiters “<%” and “%>”
• <% @Language=VBScript %>
• <% Response.Write “Presentation.” %>
equivalent to
<% =output %>
Diagram 1
Request
Clie
nt
Response
Scriptin
g
engine
Server
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Introduction to some of ASP object
Request object: The FORM collection
. Contains all information that the client has sent
<FORM METHOD=“post” ACTION=“try.asp”>
Name: <INPUT name=“name” type=“text” maxlength=“15”>
<INPUT type=“submit” value=“Submit”>
</FORM>
• <% = Request.Form(“name”) %>
or
• <% customer_name = Request.Form(“name”) %>
The customer name: <% =customer_name %>
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Introduction to some of ASP (contd …)
Response object
1. The Write method
• Channel through which information can be passed back to the client
• Syntax
– Response.Write(data)
• Alternate syntax
– <% =value %>
2. The Redirect method
• Directly redirect to the page mentioned in URL
• Syntax
– Response.Redirect URL
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Accessing data store
• Why?
– Real world  database
• How?
– Explanation …
• Steps
–
–
–
–
Connection string
Connecting to the database
Executing queries
Using Recordset Object for manipulating results
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Terminology [1]
• Active Data Object (ADO):
– Easy-to-use but extensible technology for adding database access to
the web pages.
– Adding database functionality to web application
• OLEDB:
– System level programming interface that provides standard set of COM
interfaces for exposing DBMS functionality.
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Connection to database [2]
• <%
‘create a connection object
set con = Server.CreateObject(“ADODB.connection”)
‘open connection
con.open “PROVIDER=MICROSOFT.JET.OLEDB.4.0.;”
“Data source=database extension”
%>
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Executing query
• SQL statement (INSERT, UPDATE, DELETE, SELECT)
• Execute method
• <%
SQL = “INSERT INTO table_name (att1, att2)
VALUES(‘text1’,’text2’)”
con.execute SQL
%>
• DELETE: remember
– It Delete’s all rows from the table
– Give WHERE clause
• http://www.websamba.com/sagar_asp/form.html
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Manipulating RecordSet Object [2]
•
•
•
•
Retrieve data
Display data
<% strcon = “connection string”
set con = Server.CreateObject(“ADODB.Conenction”)
con.open strcon
‘recordset object
set rs = Server.CreateObject(“ADODB.RecordSet”)
‘open recordset
SQL = “SELECT name, add FROM EMP WHERE country = ‘Canada’”
rs.open SQL,con
‘cycle and display
DO UNTIL rs.eof
%>&nbsp;<%rs(“name”) %> &nbsp; <%=rs(“add”)%>
rs.movenext
LOOP
rs.close
con.close
http://www.websamba.com/sagar_asp/form.html
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Managing database connection
• Strain database server resources when
– kept open;
– sudden increase in activity; and,
– Connection delay.
• Solution
1. Timing out a connection
– Default = 30 sec
– set con = Server.CreateObject(“ADODB.Connection”)
con.ConnectionTimeout = 20
2. Closing connection
- Reduce demand of database server
- Con.close
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Summary
• Advantages/Features
– Easy and fast way of developing non-static web pages
– Shipped with built in functions
– Use any scripting language (installed scripting engine follow the ActiveX
Scripting standard)
– Can store ASP file anywhere in server
– HTML & server side code unified
– Built in the concept of COM
•
•
•
•
ASP basics
Connecting to data store
Executing query
Using RecordSet
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
References
(1) Chris Ullman; Beginning ASP 3.0; Wrox Press; 1999.
(2) http://www.webwizguide.com/asp/tutorials/add_to_database_pt2.asp
(3) Jeffrey P. McManus; Database Access using Visual Basic; SAMS
publication; 1998.
(4) http://www.aspin.com
(5) http://www.asptoday.com
(6) http://www.asp.net
(7) http://www.asp101.com
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper
Question
?
Nov 09’ 2003
“Data Access Using ASP”
Sagar Thulung
ECMM 6010: Term Paper