TechTalk: How Do I Find ODBC Errors?

  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Q: I'm writing an application that uses ODBC from Visual Basic (VB). From time to time, I get an ODBC error, but the messages are always rather vague. For example, I often get a message saying "Error returned by the ODBC driver." However, there's no additional diagnostic information.

I know I can use the ODBC application program interfaces (APIs) to get additional error information, but I'm not using the APIs in my program. It would be somewhat difficult to switch from using the VB data control to using the APIs just to find out more about the error. I'd like to know if there is an easier way to find out what the problem is.

I've tried looking at the history log and the QSYSOPR message queue, but I don't ever see anything regarding the problem I'm having. Is there somewhere else I can look?

A: Every ODBC driver handles errors differently. However, just about every ODBC driver that I know of starts a job on the AS/400. It's that job that handles the requests you make and returns the necessary data.

Depending on your configuration, the job most often runs in the QCMN subsystem. The name may vary depending on how your PC and AS/400 are set up, but it will use the user profile you logged into the ODBC driver with. When you get the error, the job may complete or it may still be running in the subsystem.

You can start with the Work with Active Jobs (WRKACTJOB) command and look at the subsystem where your communication jobs run. Typically, but not always, your display station emulation will show with a function of *-PASSTHRU. Your ODBC job will often not display anything in the function column; you simply need to look for any jobs using your user profile.

If you don't see the job active, you need to start looking for a job log. You may need to make a change so your job produces a job log. You might also look for the job using the Work with User Jobs (WRKUSRJOB) command using your user profile.

Many of the ODBC drivers log more detailed error information into the job log. So, if you can't figure out what's wrong on the client side, give the job log on the AS/400 a try. It might have what you're looking for.

? Jim Hoopes