Microsoft KB Archive/247380

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 12:50, 21 July 2020 by X010 (talk | contribs) (Text replacement - """ to """)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


How To Simulate Long-Running SQL Calls from ASP

Article ID: 247380

Article Last Modified on 7/13/2004



APPLIES TO

  • Microsoft Active Server Pages 4.0
  • Microsoft Data Access Components 1.5
  • Microsoft Data Access Components 2.0
  • Microsoft Data Access Components 2.1
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6



This article was previously published under Q247380

SUMMARY

This articles demonstrates how to simulate long-running stored procedures from Active Server Pages (ASP) pages. You can use this sample to test connection timeouts and long-running queries.

MORE INFORMATION

  1. In a blank ASP file, copy the following code:

    <%
        Dim cnn, cmd, pa
      
            Set cnn = server.createobject("ADODB.Connection")
        set cmd = server.createobject("ADODB.Command")
    
             'This assumes you have already created a PUBS DSN
            cnn.ConnectionString = "dsn=pubs"    
            cnn.Open
    
        'TestDelay is the name of the Stored Procedure  
        cmd.CommandText = "{? = Call TestDelay (?) }"
    
        Set cmd.ActiveConnection = cnn
        cmd.parameters.refresh
        
        'Setting the delay to 5 seconds, the format is HH:MM:SS 
        cmd(1) = "0:00:05"
        response.write Now & "<BR>"
        response.flush
    
        set rs = cmd.Execute
    
        response.write rs(0)
    
        Set cmd.ActiveConnection = Nothing
        Set cmd = nothing
        set cnn = nothing
        set rs = nothing
    %>
                        
  2. Create this stored procedure in your PUBS database:

    CREATE PROC TestDelay
    @@DelayLength CHAR(9)
    AS
    BEGIN
       WAITFOR DELAY @@DelayLength
       SELECT GetDate()
    END
                        
  3. Run and test your ASP file.


Keywords: kbhowto kbsqlprog KB247380