internal static void GetDiagErrors(OdbcErrorCollection errors, string source, OdbcHandle hrHandle, RetCode retcode)
 {
     if (retcode != RetCode.SUCCESS)
     {
         short record = 0;
         short cchActual = 0;
         StringBuilder message = new StringBuilder(0x400);
         bool flag = true;
         while (flag)
         {
             int num3;
             string str;
             record = (short) (record + 1);
             retcode = hrHandle.GetDiagnosticRecord(record, out str, message, out num3, out cchActual);
             if ((RetCode.SUCCESS_WITH_INFO == retcode) && ((message.Capacity - 1) < cchActual))
             {
                 message.Capacity = cchActual + 1;
                 retcode = hrHandle.GetDiagnosticRecord(record, out str, message, out num3, out cchActual);
             }
             if ((retcode == RetCode.SUCCESS) || (retcode == RetCode.SUCCESS_WITH_INFO))
             {
                 errors.Add(new OdbcError(source, message.ToString(), str, num3));
             }
         }
     }
 }
 internal static void GetDiagErrors(OdbcErrorCollection errors, string source, OdbcHandle hrHandle, RetCode retcode)
 {
     if (retcode != RetCode.SUCCESS)
     {
         short         record    = 0;
         short         cchActual = 0;
         StringBuilder message   = new StringBuilder(0x400);
         bool          flag      = true;
         while (flag)
         {
             int    num3;
             string str;
             record  = (short)(record + 1);
             retcode = hrHandle.GetDiagnosticRecord(record, out str, message, out num3, out cchActual);
             if ((RetCode.SUCCESS_WITH_INFO == retcode) && ((message.Capacity - 1) < cchActual))
             {
                 message.Capacity = cchActual + 1;
                 retcode          = hrHandle.GetDiagnosticRecord(record, out str, message, out num3, out cchActual);
             }
             if ((retcode == RetCode.SUCCESS) || (retcode == RetCode.SUCCESS_WITH_INFO))
             {
                 errors.Add(new OdbcError(source, message.ToString(), str, num3));
             }
         }
     }
 }
Example #3
0
        internal static void GetDiagErrors(OdbcErrorCollection errors, string source, OdbcHandle hrHandle, RetCode retcode)
        {
            Debug.Assert(retcode != ODBC32.RetCode.INVALID_HANDLE, "retcode must never be ODBC32.RetCode.INVALID_HANDLE");
            if (RetCode.SUCCESS != retcode)
            {
                int   NativeError;
                short iRec      = 0;
                short cchActual = 0;

                StringBuilder message = new StringBuilder(1024);
                string        sqlState;
                bool          moreerrors = true;
                while (moreerrors)
                {
                    ++iRec;

                    retcode = hrHandle.GetDiagnosticRecord(iRec, out sqlState, message, out NativeError, out cchActual);
                    if ((RetCode.SUCCESS_WITH_INFO == retcode) && (message.Capacity - 1 < cchActual))
                    {
                        message.Capacity = cchActual + 1;
                        retcode          = hrHandle.GetDiagnosticRecord(iRec, out sqlState, message, out NativeError, out cchActual);
                    }

                    //Note: SUCCESS_WITH_INFO from SQLGetDiagRec would be because
                    //the buffer is not large enough for the error string.
                    moreerrors = (retcode == RetCode.SUCCESS || retcode == RetCode.SUCCESS_WITH_INFO);
                    if (moreerrors)
                    {
                        //Sets up the InnerException as well...
                        errors.Add(new OdbcError(
                                       source,
                                       message.ToString(),
                                       sqlState,
                                       NativeError
                                       )
                                   );
                    }
                }
            }
        }
Example #4
0
        static internal void GetDiagErrors(OdbcErrorCollection errors, string source, OdbcHandle hrHandle, RetCode retcode) {
            Debug.Assert(retcode!=ODBC32.RetCode.INVALID_HANDLE, "retcode must never be ODBC32.RetCode.INVALID_HANDLE");
            if (RetCode.SUCCESS != retcode) {
                Int32       NativeError;
                Int16       iRec            = 0;
                Int16       cchActual       = 0;

                StringBuilder message = new StringBuilder(1024);
                string sqlState;
                bool moreerrors = true;
                while(moreerrors) {

                    ++iRec;

                    retcode = hrHandle.GetDiagnosticRecord(iRec, out sqlState, message, out NativeError, out cchActual);
                    if ((RetCode.SUCCESS_WITH_INFO == retcode) && (message.Capacity-1 < cchActual)) {
                        message.Capacity = cchActual+1;
                        retcode = hrHandle.GetDiagnosticRecord(iRec, out sqlState, message, out NativeError, out cchActual);
                    }

                    //Note: SUCCESS_WITH_INFO from SQLGetDiagRec would be because
                    //the buffer is not large enough for the error string.
                    moreerrors = (retcode == RetCode.SUCCESS || retcode == RetCode.SUCCESS_WITH_INFO);
                    if(moreerrors) {
                        //Sets up the InnerException as well...
                        errors.Add(new OdbcError(
                            source,
                            message.ToString(),
                            sqlState,
                            NativeError
                            )
                        );
                    }
                }
            }
        }