示例#1
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);
        }
        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);
        }
 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 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);
        }