Solved

Handling an ODBC - CALL FAILED Error

Posted on 2000-05-08
5
826 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
[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
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 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