Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/247380

From BetaArchive Wiki
Knowledge Base

How To Simulate Long-Running SQL Calls from ASP

Article ID: 247380

Article Last Modified on 7/13/2004


  • 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


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.


  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"    
        'TestDelay is the name of the Stored Procedure  
        cmd.CommandText = "{? = Call TestDelay (?) }"
        Set cmd.ActiveConnection = cnn
        'Setting the delay to 5 seconds, the format is HH:MM:SS 
        cmd(1) = "0:00:05"
        response.write Now & "<BR>"
        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)
       WAITFOR DELAY @@DelayLength
       SELECT GetDate()
  3. Run and test your ASP file.

Keywords: kbhowto kbsqlprog KB247380