ASP Code Snippets

  1. Server Versions
  2. Enable Connection Pooling
  3. Debugging ASP
  4. Select/Case Statement example

  1. Server Versions

    response.write "Scripting engine =" & scriptengine() response.write "Buildversion =" & scriptenginebuildversion() response.write "Majorversion =" & scriptenginemajorversion() response.write "Minorversion =" & scriptengineminorversion() Set Conn = Server.CreateObject("ADODB.Connection") response.write "ado version =" & Conn.version Set tempconn = nothing Serversoftware = Request.ServerVariables("SERVER_SOFTWARE") response.write "server software =" & serversoftware Response.Write "Script Timeout =" & Server.ScriptTimeout & " seconds" Response.Write "Session Timeout =" & Session.Timeout & " minutes"
  2. Enable Connection Pooling on the server

    Two steps to take to utilize connection pooling:

    1. ensure your ASP registry settings have connection pooling enabled
    --------------------------------------------------------------------

    If this value is not set, insert this key into your registry

    HKEY_LOCAL_MACHINE
    \System
    \CurrentControlSet
    � \Services\W3SVC\ASP\Parameters

    Find the StartConnectionPool entry and change the value from 0 (zero) to 1 (one). Once this change has been made, ADO and ASP will utilize connection pooling.

    2. Set your SQL Server to use TCP/IP Sockets.
    --------------------------------------------------------------------
    Select the SQL Server Client Configuration Utility
    (via Start / Programs / Microsoft SQL Server / SQL Server Client Configuration Utility).

    Click on the Net Library tab.
    Under the Default Network setting, choose TCP/IP Sockets.

    That's all there is to it!

    (NB: Connection Pooling will not work with Access as the backend)




  3. Debugging ASP

    ... see msdn.microsoft.com/scripting/
    
    Enabling ASP Debugging
    You can use Microsoft Script Debugger to look for errors in your 
    ASP scripts. To use the debugger on your Web server, you must first
    configure the server for debugging as described in this topic. For 
    information on using the debugger to examine your scripts, see 
    Debugging ASP Scripts and the Help system for Script Debugger.
    
    To enable ASP debugging
    
    In Internet Service Manager, select the Web site or the starting point
    directory of an application. 
    Open the directory's property sheets, and then click the Home Directory,
    Virtual Directory, or Directory tab. 
    Click Configuration, then click the App Debugging tab. 
    To enable debugging, select Enable ASP Server-Side Script Debugging. 
    The debugger will be started when an error is generated from a script or 
    when ASP encounters a breakpoint in a script. 
    
    
  4. Select Case example

    MyVar = lcase (Color) Select Case MyVar Case "red" document.bgColor = "red" Case "green" document.bgColor = "green" Case "blue" document.bgColor = "blue" Case Else MsgBox "pick another color" End Select








Hosted by www.Geocities.ws

1