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
Solved

Handling an ODBC - CALL FAILED Error

Posted on 2000-05-08
5
824 Views
Last Modified: 2008-03-06
I have a program monitoring data on an AS400 using ODBC. I use ADODC objects bound to Data Grids. I want this program to run continously. Occasionally I will get an ODBC - CALL FAILED message -214767259 (80004005) which requires a response of OK before crashing and burning. I would like to trap this error so I could kill and restart the program or do a delay and retry or both. What code could I use and where would I put it to trap the error before the message box requiring the OK is issued? I know I could extend the timeouts but I would prefer to restart.

dan
0
Comment
Question by:danlevans
  • 3
  • 2
5 Comments
 
LVL 18

Expert Comment

by:mdougan
ID: 2789707
The message box that pops up is probably VB's built-in error handler.  If you wish to handle the error yourself, you need to add an error handler to any Sub or Function that might possibly generate an error (to be safe, I put one in every routine).  Here is a sample of a routine you could use:

Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)


Private Sub DoDatabaseLookup()
Dim RetryCount as long
On Error go to ErrRtn


TryAgain:
' your code goes here


ExitRtn:
Exit Sub

ErrRtn:
If Err.Number = -214767259 then
   if RetryCount < 6 then
      Retry Count = RetryCount + 1
      Sleep(10000)
      Resume TryAgain
   Else
      Printer.Print "Program stalled for over 1 minute"
      Printer.EndDoc
      End
   End if
Else
   Printer.Print Err.Number & " - " & Err.Description
   Printer.EndDoc
   Resume ExitRtn
End if

End Sub        

If you get the same error number for all different database errors, then alternatively you can search the Error Description for specific text:

ErrRtn:
If InStr(1, Err.Description, "CALL FAILED", vbTextCompare) > 0 then
    if RetryCount < 6 then
0
 
LVL 18

Expert Comment

by:mdougan
ID: 2789720
By the way, it looks like EE is not handling the the double-quotes correctly.  Most of the things that have a questionmark above are supposed to be a double-quotes (some are supposed to be amperstands), and the other comparison operators are supposed to be the greater than sign.
0
 
LVL 2

Author Comment

by:danlevans
ID: 2800245
mdougan,

I tried your suggestion and it does not trap the error.

Where would you put code to trap errors in the ADODC (not ADODB) object that is bound to a data grid on the form?

I have put error traps in all my code associated with this form.

dan
0
 
LVL 18

Accepted Solution

by:
mdougan earned 200 total points
ID: 2803104
OK, my mistake, I need to read the question more carefully.  When you have bound controls, and data controls, the data control has an Error Event that will fire if there is a problem.  Look for the Error Event and you'll see a parm that the system passes called something like fCancelDisplay.  The help file says set this to False to continue, True to display the error, but that sounds backwards.  Just display the value of fCancelDisplay, and set it to the opposite, as the default value will cause the data control to display the error and then crash the program.
0
 
LVL 2

Author Comment

by:danlevans
ID: 2804618
mdougan,

Exactly what I needed! I had played with the error method but missed the fCancelDisplay (it was off my screen) I will learn to look harder. Thanks again

dan
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

856 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