Esempio n. 1
0
        internal static bool AllocateHandle(ODBCHType handleType, ODBCHEnvironment inputHandle, out IntPtr outputHandle)
        {
            IntPtr handle;
            var    result = ODBCNativeMethods.SQLAllocHandle(handleType, inputHandle, out handle);

            outputHandle = handle;
            if ((result != ODBCResult.Success) & (result != ODBCResult.SuccessWithInfo))
            {
                throw GetException(inputHandle, "Error allocating connection handle");
            }
            return(true);
        }
Esempio n. 2
0
        internal static IntPtr AllocateEnvironmentHandle()
        {
            IntPtr handle;
            var    result = ODBCNativeMethods.SQLAllocHandle(ODBCHType.Environment, IntPtr.Zero, out handle);

            if ((result != ODBCResult.Success) && (result != ODBCResult.SuccessWithInfo))
            {
                throw new ODBCAPIError("Unable to allocate ODBC environment handle.");
            }

            return(handle);
        }
Esempio n. 3
0
        internal static bool AllocateHandle(ODBCHType handleType, IntPtr inputHandle, out IntPtr outputHandle)
        {
            IntPtr handle = IntPtr.Zero;
            var    result = ODBCNativeMethods.SQLAllocHandle(handleType, inputHandle, out handle);

            outputHandle = handle;

            if ((result != ODBCResult.Success) & (result != ODBCResult.SuccessWithInfo))
            {
                throw new ODBCAPIError("Can't allocate environment handle ");
            }

            return(true);
        }
Esempio n. 4
0
        internal static IntPtr AllocateStatementHandle(ODBCHConnection connectionHandle)
        {
            if (connectionHandle == null)
            {
                throw new ArgumentNullException("connectionHandle");
            }
            IntPtr handle;
            var    result = ODBCNativeMethods.SQLAllocHandle(ODBCHType.Statement, connectionHandle, out handle);

            if ((result == ODBCResult.Success) || (result == ODBCResult.SuccessWithInfo))
            {
                return(handle);
            }
            var ex = GetException(connectionHandle, "Unable to allocate ODBC statement handle.");

            throw ex;
        }