Presentation is loading. Please wait.

Presentation is loading. Please wait.

Swiss Federal Institute of Technology 1 Active Server Pages (ASP) n The simplest example: Additionally ASP may contain code (scripts, ActiveX controls)

Similar presentations


Presentation on theme: "Swiss Federal Institute of Technology 1 Active Server Pages (ASP) n The simplest example: Additionally ASP may contain code (scripts, ActiveX controls)"— Presentation transcript:

1 Swiss Federal Institute of Technology 1 Active Server Pages (ASP) n The simplest example: Additionally ASP may contain code (scripts, ActiveX controls) within which is interpreted by the server. Hello World ! Connect to a database (DB)  Line ASP: Simplest Example run example:

2 n 1. instantiate a server Object for an ADO-DB connection Active Server Pages (ASP) Connection to a database (DB): <% Set objConn = Server.CreateObject("ADODB.Connection") 2. open the connection to the DSN (data source name) objConn.Open "IGT-DB" 5. close connection 3. issue an SQL command and get results 4. display the results Set objList = objConn.Execute("SELECT * FROM TPersons") Do while not objList.EOF %> <% objList.MoveNext Loop objList.Close objConn.Close %> ASP objects and Management  ASP: Connection to a DB run example:

3 Swiss Federal Institute of Technology 3 ASP Session Management n Browser calls 1st ASP Start Session, i.e Run ASP end Session, i.e. New Application ? Start Application, i.e. y n create Application object fire Application_OnStart and scan Global.asa create Session object create Request object fire Session_OnStart and scan Global.asa fire Session_OnEnd ASP: Session Management

4 Swiss Federal Institute of Technology 4 ASP Session Management n Built in ASP objects (http://www.activeserverpages.com/iishelp/iis/htm/asp/iiwaobb.htm) ASP: Built in Objects

5 Swiss Federal Institute of Technology 5 Active Server Pages (ASP) n Query a DB from a Form 1st Names to search for: A simple Form: QUERY.ASP is called with parameter FirstName ASP: Query a DB from a Form run example:

6 Swiss Federal Institute of Technology 6 1. get parameter from form (Request object) Active Server Pages (ASP) n 2. add a WHERE clause with this parameter <% Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open "IGT-DB" Query a DB from a Form FName = Request("FirstName") Set objList = objConn.Execute( SQLQuery ) Do while not objList.EOF %> <% objList.MoveNext Loop objList.Close objConn.Close %> SQLQuery = "SELECT * FROM Tpersons" "WHERE TPersons.PerFirstName='" & FName & "'" + _ ASP: Display query Results run example:


Download ppt "Swiss Federal Institute of Technology 1 Active Server Pages (ASP) n The simplest example: Additionally ASP may contain code (scripts, ActiveX controls)"

Similar presentations


Ads by Google