internal OdbcConnectionHandle(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) : base(ODBC32.SQL_HANDLE.DBC, environmentHandle) {
            if(null == connection) {
                throw ADP.ArgumentNull("connection");
            }
            if(null == constr) {
                throw ADP.ArgumentNull("constr");
            }

            ODBC32.RetCode retcode;

            //Set connection timeout (only before open).
            //Note: We use login timeout since its odbc 1.0 option, instead of using
            //connectiontimeout (which affects other things besides just login) and its
            //a odbc 3.0 feature.  The ConnectionTimeout on the managed providers represents
            //the login timeout, nothing more.
            int connectionTimeout = connection.ConnectionTimeout;
            retcode = SetConnectionAttribute2(ODBC32.SQL_ATTR.LOGIN_TIMEOUT, (IntPtr)connectionTimeout, (Int32)ODBC32.SQL_IS.UINTEGER);

            string connectionString = constr.UsersConnectionString(false);

            // Connect to the driver.  (Using the connection string supplied)
            //Note: The driver doesn't filter out the password in the returned connection string
            //so their is no need for us to obtain the returned connection string
            // Prepare to handle a ThreadAbort Exception between SQLDriverConnectW and update of the state variables
            retcode = Connect(connectionString);
            connection.HandleError(this, retcode);
        }
Esempio n. 2
0
 private OdbcEnvironment () {}  // default const.
 
 static internal OdbcEnvironmentHandle GetGlobalEnvironmentHandle() {
     OdbcEnvironmentHandle globalEnvironmentHandle = _globalEnvironmentHandle as OdbcEnvironmentHandle;
     if(null == globalEnvironmentHandle) {
         ADP.CheckVersionMDAC(true);
         
         lock(_globalEnvironmentHandleLock) {
             globalEnvironmentHandle = _globalEnvironmentHandle as OdbcEnvironmentHandle;
             if(null == globalEnvironmentHandle) {
                 globalEnvironmentHandle = new OdbcEnvironmentHandle();
                 _globalEnvironmentHandle = globalEnvironmentHandle;
             }
         }
     }
     return globalEnvironmentHandle;
 }
 internal OdbcConnectionHandle(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) : base(ODBC32.SQL_HANDLE.DBC, environmentHandle)
 {
     if (connection == null)
     {
         throw ADP.ArgumentNull("connection");
     }
     if (constr == null)
     {
         throw ADP.ArgumentNull("constr");
     }
     int connectionTimeout = connection.ConnectionTimeout;
     ODBC32.RetCode retcode = this.SetConnectionAttribute2(ODBC32.SQL_ATTR.LOGIN_TIMEOUT, (IntPtr) connectionTimeout, -5);
     string connectionString = constr.UsersConnectionString(false);
     retcode = this.Connect(connectionString);
     connection.HandleError(this, retcode);
 }
Esempio n. 4
0
        }                              // default const.

        internal static OdbcEnvironmentHandle GetGlobalEnvironmentHandle()
        {
            OdbcEnvironmentHandle?globalEnvironmentHandle = s_globalEnvironmentHandle as OdbcEnvironmentHandle;

            if (null == globalEnvironmentHandle)
            {
                lock (s_globalEnvironmentHandleLock)
                {
                    globalEnvironmentHandle = s_globalEnvironmentHandle as OdbcEnvironmentHandle;
                    if (null == globalEnvironmentHandle)
                    {
                        globalEnvironmentHandle   = new OdbcEnvironmentHandle();
                        s_globalEnvironmentHandle = globalEnvironmentHandle;
                    }
                }
            }
            return(globalEnvironmentHandle);
        }
 internal static OdbcEnvironmentHandle GetGlobalEnvironmentHandle()
 {
     OdbcEnvironmentHandle handle = _globalEnvironmentHandle as OdbcEnvironmentHandle;
     if (handle == null)
     {
         ADP.CheckVersionMDAC(true);
         lock (_globalEnvironmentHandleLock)
         {
             handle = _globalEnvironmentHandle as OdbcEnvironmentHandle;
             if (handle == null)
             {
                 handle = new OdbcEnvironmentHandle();
                 _globalEnvironmentHandle = handle;
             }
         }
     }
     return handle;
 }
Esempio n. 6
0
        }                              // default const.

        static internal OdbcEnvironmentHandle GetGlobalEnvironmentHandle()
        {
            OdbcEnvironmentHandle globalEnvironmentHandle = _globalEnvironmentHandle as OdbcEnvironmentHandle;

            if (null == globalEnvironmentHandle)
            {
                ADP.CheckVersionMDAC(true);

                lock (_globalEnvironmentHandleLock) {
                    globalEnvironmentHandle = _globalEnvironmentHandle as OdbcEnvironmentHandle;
                    if (null == globalEnvironmentHandle)
                    {
                        globalEnvironmentHandle  = new OdbcEnvironmentHandle();
                        _globalEnvironmentHandle = globalEnvironmentHandle;
                    }
                }
            }
            return(globalEnvironmentHandle);
        }
Esempio n. 7
0
        internal static OdbcEnvironmentHandle GetGlobalEnvironmentHandle()
        {
            OdbcEnvironmentHandle handle = _globalEnvironmentHandle as OdbcEnvironmentHandle;

            if (handle == null)
            {
                ADP.CheckVersionMDAC(true);
                lock (_globalEnvironmentHandleLock)
                {
                    handle = _globalEnvironmentHandle as OdbcEnvironmentHandle;
                    if (handle == null)
                    {
                        handle = new OdbcEnvironmentHandle();
                        _globalEnvironmentHandle = handle;
                    }
                }
            }
            return(handle);
        }
Esempio n. 8
0
        // Construct from a compiled connection string
        internal OdbcConnectionOpen(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
        {
#if DEBUG
            try { // use this to help validate this object is only created after the following permission has been previously demanded in the current codepath
                if (null != outerConnection)
                {
                    outerConnection.UserConnectionOptions.DemandPermission();
                }
                else
                {
                    connectionOptions.DemandPermission();
                }
            }
            catch (System.Security.SecurityException) {
                System.Diagnostics.Debug.Assert(false, "unexpected SecurityException for current codepath");
                throw;
            }
#endif
            OdbcEnvironmentHandle environmentHandle = OdbcEnvironment.GetGlobalEnvironmentHandle();
            outerConnection.ConnectionHandle = new OdbcConnectionHandle(outerConnection, connectionOptions, environmentHandle);
        }
Esempio n. 9
0
        // Construct from a compiled connection string
        internal OdbcConnectionOpen(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
        {
            OdbcEnvironmentHandle environmentHandle = OdbcEnvironment.GetGlobalEnvironmentHandle();

            outerConnection.ConnectionHandle = new OdbcConnectionHandle(outerConnection, connectionOptions, environmentHandle);
        }
Esempio n. 10
0
        internal OdbcConnectionHandle(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) : base(ODBC32.SQL_HANDLE.DBC, environmentHandle)
        {
            if (null == connection)
            {
                throw ADP.ArgumentNull("connection");
            }
            if (null == constr)
            {
                throw ADP.ArgumentNull("constr");
            }

            ODBC32.RetCode retcode;

            //Set connection timeout (only before open).
            //Note: We use login timeout since its odbc 1.0 option, instead of using
            //connectiontimeout (which affects other things besides just login) and its
            //a odbc 3.0 feature.  The ConnectionTimeout on the managed providers represents
            //the login timeout, nothing more.
            int connectionTimeout = connection.ConnectionTimeout;

            retcode = SetConnectionAttribute2(ODBC32.SQL_ATTR.LOGIN_TIMEOUT, (IntPtr)connectionTimeout, (Int32)ODBC32.SQL_IS.UINTEGER);

            string connectionString = constr.UsersConnectionString(false);

            // Connect to the driver.  (Using the connection string supplied)
            //Note: The driver doesn't filter out the password in the returned connection string
            //so their is no need for us to obtain the returned connection string
            // Prepare to handle a ThreadAbort Exception between SQLDriverConnectW and update of the state variables
            retcode = Connect(connectionString);
            connection.HandleError(this, retcode);
        }
Esempio n. 11
0
 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetEnvAttr(
     /*SQLHENV*/OdbcEnvironmentHandle EnvironmentHandle,
     /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute,
     /*SQLPOINTER*/IntPtr Value,
     /*SQLINTEGER*/ODBC32.SQL_IS StringLength);
        internal OdbcConnectionHandle(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) : base(ODBC32.SQL_HANDLE.DBC, environmentHandle)
        {
            if (connection == null)
            {
                throw ADP.ArgumentNull("connection");
            }
            if (constr == null)
            {
                throw ADP.ArgumentNull("constr");
            }
            int connectionTimeout = connection.ConnectionTimeout;

            ODBC32.RetCode retcode          = this.SetConnectionAttribute2(ODBC32.SQL_ATTR.LOGIN_TIMEOUT, (IntPtr)connectionTimeout, -5);
            string         connectionString = constr.UsersConnectionString(false);

            retcode = this.Connect(connectionString);
            connection.HandleError(this, retcode);
        }
 internal static extern ODBC32.RetCode SQLSetEnvAttr(OdbcEnvironmentHandle EnvironmentHandle, ODBC32.SQL_ATTR Attribute, IntPtr Value, ODBC32.SQL_IS StringLength);