PRB: DB-Library Application Exits to Command Prompt

Last reviewed: April 28, 1997
Article ID: Q105019

The information in this article applies to:

  - Microsoft SQL Server Programmer's Toolkit, version 4.2

SYMPTOMS

A character mode DB-Library application exits to the operating system command prompt, often without any errors or messages. This frequently occurs on a call to dbopen.

CAUSE

The DB-Library application's error handler is likely returning INT_EXIT. This tells DB-Library to completely and immediately exit the application, and return to the operating system command prompt.

NOTE: The DB-Library sample error handlers contain code similar to the following:

     if ((dbproc == NULL) || (DBDEAD(dbproc)))
         return(INT_EXIT);

For example, if the dbopen function fails for any reason, a NULL DBPROCESS pointer is passed to the error handler along with DB-Library error 10004. This will cause the above code to return INT_EXIT, which as stated above will immediately exit the application.

WORKAROUND

Ensure that the application's error handler returns INT_CANCEL instead of INT_EXIT, similar to the following:

     if ((dbproc == NULL) || (DBDEAD(dbproc)))
         return(INT_CANCEL);

Returning INT_CANCEL tells DB-Library to simply return FAIL from the current DB-Library function. Otherwise, ensure that the application displays an appropriate message before returning INT_EXIT, similar to the following:

     printf("DB-Library Error %i: %s\n", dberr, dberrstr);
     if ((dbproc == NULL) || (DBDEAD(dbproc)))
         return(INT_EXIT);


Additional query words: exit quit crash dblib
Keywords : kbprg SSrvDB_Lib SSrvProg
Version : 4.2 | 4.2 | 4.2
Platform : MS-DOS OS/2 WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.