1,105,221 Community Members

Handle SQL timeout with custom message to the user

Member Avatar
ritesh0104
Newbie Poster
8 posts since Dec 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

an asp page of mine with server.ScriptTimeout=540 seconds
this page is then executing a select query from a huge database table which is properly indexed

BUT
few times there is a SQL timeout because of conditions passed in query

is there a way to handle the SQL timeout and display a user friendly message to the user to refine the search conditions.

            dim adocon
            set adocon=server.CreateObject("ADODB.Connection")
            adocon.ConnectionTimeout=300
            adocon.CommandTimeout=300
            adocon.open myConnection

            dim rs
            set rs=server.CreateObject("ADODB.Recordset")
            rs.CursorLocation=adUseClient
            rs.open "my query goes here", adocon

my Server:
- Windows Server 2008
- MS SQL Server 2008 R2

Member Avatar
JorgeM
IT Addict
6,378 posts since Dec 2011
Reputation Points: 567 [?]
Q&As Helped to Solve: 951 [?]
Skill Endorsements: 172 [?]
Moderator
Featured
Sponsor
 
3
 

As you may already know, ASP doesn't provide a try...catch block for you to trap errors.

The closest approach would be something like this...

On Error Resume Next 
'Try....
code that can fail here.........

If Err.Number<>0 Then
'Catch...
   Response.Write("an error has occurred. Description: " & Err.Description)
End If
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: