Solved

User Friendly Timeout Message for SQL Server (0x80040E31)

Posted on 2002-05-28
6
2,339 Views
Last Modified: 2008-03-03
I would like capture the timeout error and present a user  friendly message to ask him/her to narrow their search.

I do not want to extend the connection time.  The strangest part of this issue is that it doesn't timeout when I hit back and click the search button again.

This is the error that I receive:
Microsoft OLE DB Provider for SQL Server (0x80040E31)
Timeout expired

thank you for your help

0
Comment
Question by:the69void
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 9

Expert Comment

by:Nitin Sontakke
ID: 7040637
At the face of it, this doesnot have anything to do with timeout. The fact that it doesn't happen second time.

Have you tried running the query in Query Analyzer directly. See how long it takes there.
0
 

Expert Comment

by:jerry2yu
ID: 7040748
Hi the69void,

Please try something like the following,

       try{
          string strConn;
          strConn="server=sqlserver2.bbc.com;database=***;UID=***;PWD=***;";
          SqlConnection myConn = new SqlConnection(strConn) ;
          myConn.Open();
          String strSQL;
          strSQL = "update userinformation set Company='" + strCompany + "'";          SqlCommand updateCMD = new SqlCommand(strSQL, myConn);
          Int32 _totalRecords = (Int32)updateCMD.ExecuteNonQuery();
          myConn.Close();
          ResultMessage.Text =_totalRecords.ToString() + " record updated successfully.";
      }
     catch (Exception  eException){
          ResultMessage.Text=eException.Message;
     }
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 7042085
You catch the timeout error just as any other database error:

On Error Resume Next
Set rstResult=cnnDb.Execute(strSQL)
If cnnDb.Errors.Count=0 Then
   ' show the result
Else
   ' handle the error
End If
On Error Goto 0
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:the69void
ID: 7043172
I cannot use On Error Resume Next.  Because "it doesn't trap the errors, it lets them run away never to return."
http://www.infinitemonkeys.ws/infinitemonkeys/articles/asp/943.asp

Also, I'm not using ASP.net ... so I'm assuming try/catch would be Javascript which I'm truly weak in.

As for running the store procedure in Query Analyzer... yes it takes awhile depending on the user's parameter.  Regardless of the intermittent time out, which usually occur the first time they try to run the search, all I want is to capture the timeout and ask the to narrow their search.
0
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 100 total points
ID: 7043399
There is no problem in using On Error Resume Next, as long as you only use it where it's needed, and turn the error checking on again.

Atrax is using that example of bad error handling to imply that the error handling of JScript is far better, but I've seen the same fault being made using try...catch also. Bad code can be written in any language, but it doesn't mean that the language is bad.

Although the error handling in VBScript is somewhat awkward, it's still sufficient for writing professional applications.

The thing to remember when you turn the error checking off in VBScript, is that you have to check for errors after every command that can produce one. That's why you should turn on the error checing again as soon as possible.

The error checking is turned on again with:
On Error Goto 0

Also, if you turn the error checking off inside a sub or function, it's turned on again when you leave it.
0
 

Author Comment

by:the69void
ID: 7112550
The database guy improved the store procedure .... and I extended the connection time...   Thank you for your assistance.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question