예제 #1
0
        // non-throwing HandleError
        internal Exception HandleErrorNoThrow(OdbcHandle hrHandle, ODBC32.RetCode retcode)
        {
            Debug.Assert(retcode != ODBC32.RetCode.INVALID_HANDLE, "retcode must never be ODBC32.RetCode.INVALID_HANDLE");

            switch (retcode)
            {
            case ODBC32.RetCode.SUCCESS:
                break;

            case ODBC32.RetCode.SUCCESS_WITH_INFO:
            {
                //Optimize to only create the event objects and obtain error info if
                //the user is really interested in retriveing the events...
                if (_infoMessageEventHandler != null)
                {
                    OdbcErrorCollection errors = ODBC32.GetDiagErrors(null, hrHandle, retcode);
                    errors.SetSource(this.Driver);
                    OnInfoMessage(new OdbcInfoMessageEventArgs(errors));
                }
                break;
            }

            default:
                OdbcException e = OdbcException.CreateException(ODBC32.GetDiagErrors(null, hrHandle, retcode), retcode);
                if (e != null)
                {
                    e.Errors.SetSource(this.Driver);
                }
                ConnectionIsAlive(e);            // this will close and throw if the connection is dead
                return((Exception)e);
            }
            return(null);
        }
예제 #2
0
        internal Exception HandleErrorNoThrow(OdbcHandle hrHandle, ODBC32.RetCode retcode)
        {
            switch (retcode)
            {
            case ODBC32.RetCode.SUCCESS:
                break;

            case ODBC32.RetCode.SUCCESS_WITH_INFO:
                if (this.infoMessageEventHandler != null)
                {
                    OdbcErrorCollection errors = ODBC32.GetDiagErrors(null, hrHandle, retcode);
                    errors.SetSource(this.Driver);
                    this.OnInfoMessage(new OdbcInfoMessageEventArgs(errors));
                }
                break;

            default:
            {
                OdbcException innerException = OdbcException.CreateException(ODBC32.GetDiagErrors(null, hrHandle, retcode), retcode);
                if (innerException != null)
                {
                    innerException.Errors.SetSource(this.Driver);
                }
                this.ConnectionIsAlive(innerException);
                return(innerException);
            }
            }
            return(null);
        }