Index   Search   Add FAQ   Ask Question  
 

Please note: This page is not maintained anymore. Please visit the new and improved page at http://www.orafaq.com/wiki/ASP

Oracle/ Active Server Pages FAQ

$Date: 14-Dec-2001 $
$Revision: 1.00 $
$Author: Frank Naudé $

Topics

  • What is ASP and what is it used for?
  • What is the difference between ASP and JSP?
  • What Web Servers can be used for hosting ASP pages?
  • How does one configure ASP servers for Oracle?
  • How does one connect to Oracle from an ASP page?
  • How does one call stored procedures from an ASP page?
  • Where can one get more info about ASP?

  • Back to Oracle FAQ Index

    What is ASP and what is it used for?

    Active(X) Server Pages (ASP) is a language-independent framework designed by Microsoft to generate dynamic web content. It allows coding of server-side scripts that are executed by a Web server in response to a user's request for a URL. ASP scripts are similar to other server-side scripting technologies like Java Server Pages, Perl Server Pages and so on.

    An ASP page is a standard ASCII text file that contains both HTML tags and scripting code. Typical scripting languages that can be embedded into ASP pages are VBScript and JavaScript. All scripting portions are delimited by <% and %> tags. Example ASP page:

    	<html>
    	Current date and time is:
    	<%
    	  ' Start comments with "'"
    	  response.write "<B>"
    	  response.write Now() ' writes the current date and time.
    	%>
    	</html>
    
  • Back to top of file

  • What is the difference between ASP and JSP?

    Active Server Pages (ASP) is a Microsoft standard, which is easier to develop than Java Server Pages (JSP). ASP supports multiple scripting languages (VBScript, JavaScript, etc), but is limited to Microsoft supported platforms and software.

    JSP supports customizable tags and is independent of platform and server technologies. Code is developed using the standard Java programming language. Either ODBC or JDBC is used to connect to Oracle (and other) databases. JSP is usually used for larger enterprise scale applications. For more information about JSP Pages, see the JDBC FAQ.

  • Back to top of file

  • What Web Servers can be used for hosting ASP pages?

    Active Server Pages are supported on the following Web Servers:

  • Back to top of file

  • How does one configure ASP servers for Oracle?

    Follow these steps to ensure your server can connect to Oracle:
    1. Make sure that you can use simple ASP pages. Upload (FTP) the example above to your server and see if you can access it via a Web Browser.

    2. Install the Oracle Client CD on your server. This will install SQL*Net, OO4O (Oracle Objects for OLE) and the Oracle ODBC drivers on your system.

    3. Configure SQL*Net and ensure you can tnsping and connect your Oracle database. This is done by adding an entry to the TNSNAMES.ORA file or by using utilities like the "Net Easy Configurator" to do it for you. See the SQL*Net FAQ for details.

    4. Optionally configure ODBC by creating a System DSN (Data Source Name). This can be done from the "32-Bit ODBC Administrator" in the Control Pannel. Alternatively one can use OO4O (no configuration required), or "DSNless" ODBC connection. See the ODBC FAQ for details.

    5. You are ready to GO!!!

  • Back to top of file

  • How does one connect to Oracle from an ASP page?

    One can connect to Oracle from ASP Pages using the Oracle ODBC driver or OO4O (Oracle Objects for OLE) calls. Look at this OO4O example:
    	<%
    	   Set OraSession  = Server.CreateObject("OracleInProcServer.XOraSession")
    	   Set OraDatabase = OraSession.DbOpenDatabase("connect_str.world", "hr/hr",cint(0))
    
    	   Response.Write "OO4O Version:   " & OraSession.OIPVersionNumber & "<BR>" & _ 
    	                  "Username:       " & OraDatabase.connect         & "<BR>" & _
    	                  "Database Name:  " & OraDatabase.DatabaseName    & "<BR>" & _ 
    	                  "Oracle Version: " & OraDatabase.RDBMSVersion    & "<BR>"
    						  
    	   Set osRecordSet = OraDatabase.DbCreateDynaset("SELECT TNAME FROM TAB", cint(0))		   
    	   Response.write("<H1>Tables:</H1>")
    		   		   
    	   Do While(osRecordset.EOF = FALSE)
    	      Response.write(osRecordset.Fields("TNAME") & "<BR>")
    	      osRecordSet.MoveNext
    	   Loop
    	%>
    
    The following example domonstrated ODBC connectivity:
    	<%
    	  Set OraDatabase = Server.CreateObject("ADODB.Connection")
    	  OraDatabase.Open "dsn=OracleDSN;uid=userid;pwd=password;"
    	  Set osRecordSet = OraDatabase.Execute("SELECT * FROM EMPLOYEE")
    	  Response.Write "<table border=1 cellpadding=4>"
    	  Response.Write "<tr>"
    
    	  For I = 0 To osRecordSet.Fields.Count - 1
    	      Response.Write "<td><b>" & osRecordSet(I).Name & "</b></td>"
    	  Next
    
    	  Response.Write "</tr>"
    
    	  Do While Not osRecordSet.EOF
    	     Response.Write "<tr>"
    	     For I = 0 To osRecordSet.Fields.Count - 1
    	         Response.Write "<td>" & osRecordSet(I) & "</td>"
    	     Next
    	     Response.Write "</tr>"
    	     osRecordSet.MoveNext
    	  Loop
    
    	  Response.Write "</table>"
    
    	  osRecordSet.Close
    	  OraDatabase.Close
    	%>
    

  • Back to top of file

  • How does one call stored procedures from an ASP page?

    See the OO4O FAQ for details. The OO4O also conatians

  • Back to top of file

  • Where can one get more info about ASP?

  • Back to top of file
  • HOME | ASK QUESTION | ADD FAQ | SEARCH | E-MAIL US