Microsoft KB Archive/247380: Difference between revisions
From BetaArchive Wiki
m (Text replacement - "&" to "&") |
m (Text replacement - """ to """) |
||
Line 61: | Line 61: | ||
Dim cnn, cmd, pa | Dim cnn, cmd, pa | ||
Set cnn = server.createobject( | Set cnn = server.createobject("ADODB.Connection") | ||
set cmd = server.createobject( | set cmd = server.createobject("ADODB.Command") | ||
'This assumes you have already created a PUBS DSN | 'This assumes you have already created a PUBS DSN | ||
cnn.ConnectionString = | cnn.ConnectionString = "dsn=pubs" | ||
cnn.Open | cnn.Open | ||
'TestDelay is the name of the Stored Procedure | 'TestDelay is the name of the Stored Procedure | ||
cmd.CommandText = | cmd.CommandText = "{? = Call TestDelay (?) }" | ||
Set cmd.ActiveConnection = cnn | Set cmd.ActiveConnection = cnn | ||
Line 75: | Line 75: | ||
'Setting the delay to 5 seconds, the format is HH:MM:SS | 'Setting the delay to 5 seconds, the format is HH:MM:SS | ||
cmd(1) = | cmd(1) = "0:00:05" | ||
response.write Now & | response.write Now & "<BR>" | ||
response.flush | response.flush | ||
Latest revision as of 13:50, 21 July 2020
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
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 %>
Create this stored procedure in your PUBS database:
CREATE PROC TestDelay @@DelayLength CHAR(9) AS BEGIN WAITFOR DELAY @@DelayLength SELECT GetDate() END
- Run and test your ASP file.
Keywords: kbhowto kbsqlprog KB247380