Microsoft KB Archive/105019: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 75: Line 75:
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:<br />
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:<br />


<pre class="codesample">    printf(&quot;DB-Library Error %i: %s\n&quot;, dberr, dberrstr);
<pre class="codesample">    printf("DB-Library Error %i: %s\n", dberr, dberrstr);
     if ((dbproc == NULL) || (DBDEAD(dbproc)))
     if ((dbproc == NULL) || (DBDEAD(dbproc)))
         return(INT_EXIT);
         return(INT_EXIT);

Latest revision as of 09:41, 20 July 2020

Knowledge Base


PRB: DB-Library Application Exits to Command Prompt

Article ID: 105019

Article Last Modified on 2/22/2005



APPLIES TO

  • Microsoft SQL Server 4.21a Standard Edition
  • Microsoft SQL Server 6.5 Standard Edition



This article was previously published under Q105019

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: kbprogramming KB105019