Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 Session 6 Server-side programming - ASP

2 An ASP page is an HTML page interspersed with server-side code. The.ASP extension instead of.HTM denotes server-side code to the hosting Web server. You can use any text editor to create or change an ASP file <% var varSurname = Request.form("surname") ; %> <% sql = "Select * from tblStock" %> THIS IS HTML Surname: What is ASP? Sets the default for the page The ASP is between Gets data from form on previous page Outputs the variable’s content

3 Open Database Connectivity (ODBC) ODBC is an intermediary technology that allows databases made by different manufacturers to communicate with different interfaces e.g. ASP pages. The web server has ODBC drivers installed upon it which interpret the dialogue into a common language that each database understands. OracleAccessDB2 ODBC All you need to know is how to interact with me. Ask me for data and I will get it for you. Adapted from Resselman, 2000 These databases know how to interact with ODBC

4 Browsers Display data primarily in HTML format. Accept user input from HTML form elements ASP pages are a mixture of hard-coded HTML (menu bars, other static page content) and dynamically generated HTML. ASP (operating at the server-side) must therefore send the data from the server to the client in HTML format. All the calculations for doing this are performed at the server side, using the server's processor.

5 Client Web Server Database ActiveX Data Objects (ADO) Components IIS VBScript JavaScript ActiveX Scripting Engines ASP File HTTP Request HTTP Response

6 1.Client requests ASP page from server 2.HTML and script code are separated. 3.Script code is parsed, syntax checked and compiled by Web server by appropriate scripting engine 4.Code is executed by the appropriate scripting engine 5.Script output and static HTML code are merged 6.Final HTML is sent back to the user Stages for ASP

7 Anatomy of an.asp Page The HTML element including the usual tags e.g.. Script executed at the server end. The server then responds with dynamic content e.g. returning a recordset. More HTML, representing any static content of the page. Note: the code appears where the data will be output on screen.

8 Returning Records from a DB Using ASP Open a connection to the database, using the connection object. Create a query string variable containing the SQL for the query. Create a recordset object, then run the query on it. Loop through the records and format and display each as HTML.

9 <% myconn = CreateObject("ADODB.Connection " ); rs = CreateObject("ADODB.Recordset"); myDB = "Driver={Microsoft Access Driver (*.mdb)};DBQ=e:\\webareas\\sr65\\sdg.mdb"; Denotes start of JavaScript Assigns objects to the connection and recordset variables

10 sql = "Select * from tblStock order by Stock_id"; rs=myconn.Execute(sql); while (! rs.eof) {%> Item: <% rs.MoveNext } rs.Close %> Opens the recordset and runs the query on it. Assigns a SQL command in string data type to the SQL variable. NOT (End of file.) Outputs each record as HTML. Loops from beginning to end of the record set, writing the content of the description field into the document. Closes the recordset


Download ppt "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."

Similar presentations


Ads by Google