Exemplo n.º 1
0
        internal static void HandleWarnings(ICreateErrors source, IDbConnection connection)
        {
            VirtuosoErrorCollection      errors = source.CreateErrors();
            VirtuosoInfoMessageEventArgs args   = new VirtuosoInfoMessageEventArgs(errors);

            ((VirtuosoConnection)connection).OnInfoMessage(args);
        }
Exemplo n.º 2
0
        public VirtuosoErrorCollection CreateErrors()
        {
            VirtuosoErrorCollection e = errors.CreateErrors();

            errors.Clear();
            return(e);
        }
Exemplo n.º 3
0
        private static VirtuosoErrorCollection CreateErrors(CLI.ReturnCode rc)
        {
            string message = null;

            switch (rc)
            {
            case CLI.ReturnCode.SQL_INVALID_HANDLE:
                message = "Invalid Handle";
                break;

            case CLI.ReturnCode.SQL_NEED_DATA:
                message = "Need Data";
                break;

            case CLI.ReturnCode.SQL_STILL_EXECUTING:
                message = "Still Executing";
                break;

            default:
                message = "Unexpected Return Code";
                break;
            }

            VirtuosoErrorCollection errors = new VirtuosoErrorCollection();
            VirtuosoError           error  = new VirtuosoError(message, "");

            errors.Add(error);
            return(errors);
        }
Exemplo n.º 4
0
 internal void AddWarning(string state, string message)
 {
     Debug.WriteLineIf(CLI.FnTrace.Enabled, "ManagedErrors.Warning (state = '" + state + "', message = '" + message + "')");
     if (errors == null)
     {
         errors = new VirtuosoErrorCollection();
     }
     errors.Add(new VirtuosoWarning(message, state));
 }
Exemplo n.º 5
0
        internal static VirtuosoErrorCollection CreateErrors(CLI.HandleType handleType, IntPtr handle)
        {
            VirtuosoErrorCollection errors = new VirtuosoErrorCollection();

            MemoryHandle sqlState    = null;
            MemoryHandle messageText = null;

            try
            {
                sqlState    = new MemoryHandle((CLI.SQL_SQLSTATE_SIZE + 1) * Platform.WideCharSize);
                messageText = new MemoryHandle((CLI.SQL_MAX_MESSAGE_LEN + 1) * Platform.WideCharSize);

                for (short recNumber = 1; ; recNumber++)
                {
                    int            nativeError;
                    short          textLength;
                    CLI.ReturnCode rc = (CLI.ReturnCode)CLI.SQLGetDiagRec(
                        (short)handleType,
                        handle,
                        recNumber,
                        sqlState.Handle,
                        out nativeError,
                        messageText.Handle,
                        (short)(messageText.Length / Platform.WideCharSize),
                        out textLength);
                    if (rc != CLI.ReturnCode.SQL_SUCCESS && rc != CLI.ReturnCode.SQL_SUCCESS_WITH_INFO)
                    {
                        break;
                    }

#if false
                    //System.Console.WriteLine ("length: {0}", textLength);
                    string sMessageText = Platform.WideCharsToString(messageText.Handle, textLength);
                    string sSqlState    = Platform.WideCharsToString(sqlState.Handle, CLI.SQL_SQLSTATE_SIZE);
#else
                    string sMessageText = Marshal.PtrToStringAnsi(messageText.Handle, textLength);
                    string sSqlState    = Marshal.PtrToStringAnsi(sqlState.Handle, CLI.SQL_SQLSTATE_SIZE);
#endif
                    VirtuosoError error = new VirtuosoError(sMessageText, sSqlState);
                    errors.Add(error);
                }
            }
            finally
            {
                if (sqlState != null)
                {
                    sqlState.Dispose();
                }
                if (messageText != null)
                {
                    messageText.Dispose();
                }
            }

            return(errors);
        }
Exemplo n.º 6
0
        internal static void HandleErrors(CLI.ReturnCode returnCode, ICreateErrors source)
        {
            VirtuosoErrorCollection errors = null;

            if (returnCode == CLI.ReturnCode.SQL_ERROR)
            {
                errors = source.CreateErrors();
            }
            else
            {
                errors = CreateErrors(returnCode);
            }
            throw new VirtuosoException(returnCode, errors);
        }
		internal static VirtuosoErrorCollection CreateErrors (CLI.HandleType handleType, IntPtr handle)
		{
			VirtuosoErrorCollection errors = new VirtuosoErrorCollection ();

			MemoryHandle sqlState = null;
			MemoryHandle messageText = null;
			try
			{
				sqlState = new MemoryHandle ((CLI.SQL_SQLSTATE_SIZE + 1) * Platform.WideCharSize);
				messageText = new MemoryHandle ((CLI.SQL_MAX_MESSAGE_LEN + 1) * Platform.WideCharSize);

				for (short recNumber = 1; ;recNumber++)
				{
					int nativeError;
					short textLength;
					CLI.ReturnCode rc = (CLI.ReturnCode) CLI.SQLGetDiagRec (
						(short) handleType,
						handle,
						recNumber,
						sqlState.Handle,
						out nativeError,
						messageText.Handle,
						(short) (messageText.Length / Platform.WideCharSize),
						out textLength);
					if (rc != CLI.ReturnCode.SQL_SUCCESS && rc != CLI.ReturnCode.SQL_SUCCESS_WITH_INFO)
						break;

#if false
					//System.Console.WriteLine ("length: {0}", textLength);
					string sMessageText = Platform.WideCharsToString (messageText.Handle, textLength);
					string sSqlState = Platform.WideCharsToString (sqlState.Handle, CLI.SQL_SQLSTATE_SIZE);
#else
					string sMessageText = Marshal.PtrToStringAnsi (messageText.Handle, textLength);
					string sSqlState = Marshal.PtrToStringAnsi (sqlState.Handle, CLI.SQL_SQLSTATE_SIZE);
#endif
					VirtuosoError error = new VirtuosoError (sMessageText, sSqlState);
					errors.Add (error);
				}
			} 
			finally 
			{
				if (sqlState != null)
					sqlState.Dispose ();
				if (messageText != null)
					messageText.Dispose ();
			}

			return errors;
		}
Exemplo n.º 8
0
        // deprecated
        internal static void HandleErrors(
            CLI.ReturnCode returnCode,
            CLI.HandleType handleType,
            IntPtr handle)
        {
            VirtuosoErrorCollection errors = null;

            if (returnCode == CLI.ReturnCode.SQL_ERROR)
            {
                errors = OdbcErrors.CreateErrors(handleType, handle);
            }
            else
            {
                errors = CreateErrors(returnCode);
            }
            throw new VirtuosoException(returnCode, errors);
        }
Exemplo n.º 9
0
 internal VirtuosoException(CLI.ReturnCode returnCode, VirtuosoErrorCollection errors)
 {
     this.returnCode = returnCode;
     this.errors     = errors;
 }
Exemplo n.º 10
0
 internal void Clear()
 {
     errors = null;
 }
		private static VirtuosoErrorCollection CreateErrors (CLI.ReturnCode rc)
		{
			string message = null;
			switch (rc)
			{
			case CLI.ReturnCode.SQL_INVALID_HANDLE:
				message = "Invalid Handle";
				break;
			case CLI.ReturnCode.SQL_NEED_DATA:
				message = "Need Data";
				break;
			case CLI.ReturnCode.SQL_STILL_EXECUTING:
				message = "Still Executing";
				break;
			default:
				message = "Unexpected Return Code";
				break;
			}

			VirtuosoErrorCollection errors = new VirtuosoErrorCollection ();
			VirtuosoError error = new VirtuosoError (message, "");
			errors.Add (error);
			return errors;
		}
		internal void Clear ()
		{
			errors = null;
		}
		internal void AddWarning (string state, string message)
		{
			Debug.WriteLineIf (CLI.FnTrace.Enabled, "ManagedErrors.Warning (state = '" + state + "', message = '" + message + "')");
			if (errors == null)
				errors = new VirtuosoErrorCollection ();
			errors.Add (new VirtuosoWarning (message, state));
		}
		internal VirtuosoException (CLI.ReturnCode returnCode, VirtuosoErrorCollection errors)
		{
			this.returnCode = returnCode;
			this.errors = errors;
		}
		internal VirtuosoInfoMessageEventArgs (VirtuosoErrorCollection errors)
		{
			this.errors = errors;
		}
Exemplo n.º 16
0
 internal VirtuosoInfoMessageEventArgs(VirtuosoErrorCollection errors)
 {
     this.errors = errors;
 }