170 likes | 305 Views
ECMM 6010: TERM PAPER PRESENTATION. Data Access Using Active Server Page (ASP). Sagar Thulung (B00349076) MEC Candidate. Table of content. ASP Introduction Requirement Basic of ASP coding Introduction to some of the ASP objects Accessing data store Connecting string
E N D
ECMM 6010: TERM PAPER PRESENTATION Data Access UsingActive Server Page (ASP) Sagar Thulung (B00349076) MEC Candidate “Data Access Using ASP” Sagar Thulung
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 “Data Access Using ASP” Sagar Thulung
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. “Data Access Using ASP” Sagar Thulung
Requirement • Text editor (notepad, Visual InterDev, …) • Browser • Server (PWS, IIS) • Others • DBMS • Image editing tools • … • Limitation: • - Limited to MS Win based platform • - PWS: • Runs in Win 9X only • About 20 concurrent users only “Data Access Using ASP” Sagar Thulung
Basic of ASP coding • Enclosed between delimiters “<%” and “%>” • <% @Language=VBScript %> • <% Response.Write “Presentation.” %> equivalent to <% =output %> Diagram 1 Request Scripting engine Server Client Response “Data Access Using ASP” Sagar Thulung
Introduction to some of ASP object Request object: The FORM collection . Contains all information that the client has sent • <% = Request.Form(“name”) %> or • <% customer_name = Request.Form(“name”) %> The customer name: <% =customer_name %> <FORM METHOD=“post” ACTION=“try.asp”> Name: <INPUT name=“name” type=“text” maxlength=“15”> <INPUT type=“submit” value=“Submit”> </FORM> “Data Access Using ASP” Sagar Thulung
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 “Data Access Using ASP” Sagar Thulung
Accessing data store • Why? • Real world database • How? • Explanation … • Steps • Connection string • Connecting to the database • Executing queries • Using Recordset Object for manipulating results “Data Access Using ASP” Sagar Thulung
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. “Data Access Using ASP” Sagar Thulung
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” %> “Data Access Using ASP” Sagar Thulung
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 “Data Access Using ASP” Sagar Thulung
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 %> <%rs(“name”) %> <%=rs(“add”)%> rs.movenext LOOP rs.close con.close • http://www.websamba.com/sagar_asp/form.html “Data Access Using ASP” Sagar Thulung
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 “Data Access Using ASP” Sagar Thulung
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 “Data Access Using ASP” Sagar Thulung
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 “Data Access Using ASP” Sagar Thulung
Question ? “Data Access Using ASP” Sagar Thulung