コード例 #1
0
        internal void Open_EnlistTransaction(SysTx.Transaction transaction)
        {
            OdbcConnection.VerifyExecutePermission();

            if ((null != this.weakTransaction) && this.weakTransaction.IsAlive)
            {
                throw ADP.LocalTransactionPresent();
            }

            SysTx.IDtcTransaction oleTxTransaction = ADP.GetOletxTransaction(transaction);

            OdbcConnectionHandle connectionHandle = ConnectionHandle;

            ODBC32.RetCode retcode;
            if (null == oleTxTransaction)
            {
                retcode = connectionHandle.SetConnectionAttribute2(ODBC32.SQL_ATTR.SQL_COPT_SS_ENLIST_IN_DTC, (IntPtr)ODBC32.SQL_DTC_DONE, ODBC32.SQL_IS_PTR);
            }
            else
            {
                retcode = connectionHandle.SetConnectionAttribute4(ODBC32.SQL_ATTR.SQL_COPT_SS_ENLIST_IN_DTC, oleTxTransaction, ODBC32.SQL_IS_PTR);
            }

            if (retcode != ODBC32.RetCode.SUCCESS)
            {
                HandleError(connectionHandle, retcode);
            }

            // Tell the base class about our enlistment
            ((OdbcConnectionOpen)InnerConnection).EnlistedTransaction = transaction;
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         OdbcConnectionHandle hrHandle = this._handle;
         this._handle = null;
         if (hrHandle != null)
         {
             try
             {
                 ODBC32.RetCode retcode = hrHandle.CompleteTransaction(1);
                 if ((retcode == ODBC32.RetCode.ERROR) && (this._connection != null))
                 {
                     ADP.TraceExceptionWithoutRethrow(this._connection.HandleErrorNoThrow(hrHandle, retcode));
                 }
             }
             catch (Exception exception)
             {
                 if (!ADP.IsCatchableExceptionType(exception))
                 {
                     throw;
                 }
             }
         }
         if ((this._connection != null) && this._connection.IsOpen)
         {
             this._connection.LocalTransaction = null;
         }
         this._connection = null;
         this._isolevel = System.Data.IsolationLevel.Unspecified;
     }
     base.Dispose(disposing);
 }
コード例 #3
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         OdbcConnectionHandle hrHandle = this._handle;
         this._handle = null;
         if (hrHandle != null)
         {
             try
             {
                 ODBC32.RetCode retcode = hrHandle.CompleteTransaction(1);
                 if ((retcode == ODBC32.RetCode.ERROR) && (this._connection != null))
                 {
                     ADP.TraceExceptionWithoutRethrow(this._connection.HandleErrorNoThrow(hrHandle, retcode));
                 }
             }
             catch (Exception exception)
             {
                 if (!ADP.IsCatchableExceptionType(exception))
                 {
                     throw;
                 }
             }
         }
         if ((this._connection != null) && this._connection.IsOpen)
         {
             this._connection.LocalTransaction = null;
         }
         this._connection = null;
         this._isolevel   = System.Data.IsolationLevel.Unspecified;
     }
     base.Dispose(disposing);
 }
コード例 #4
0
        private string GetInfoStringUnhandled(ODBC32.SQL_INFO info, bool handleError)
        {
            string str      = null;
            short  cbActual = 0;

            byte[] buffer = new byte[100];
            OdbcConnectionHandle connectionHandle = this.ConnectionHandle;

            if (connectionHandle != null)
            {
                ODBC32.RetCode retcode = connectionHandle.GetInfo2(info, buffer, out cbActual);
                if (buffer.Length < (cbActual - 2))
                {
                    buffer  = new byte[cbActual + 2];
                    retcode = connectionHandle.GetInfo2(info, buffer, out cbActual);
                }
                if ((retcode == ODBC32.RetCode.SUCCESS) || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO))
                {
                    return(Encoding.Unicode.GetString(buffer, 0, Math.Min(cbActual, buffer.Length)));
                }
                if (handleError)
                {
                    this.HandleError(this.ConnectionHandle, retcode);
                }
                return(str);
            }
            if (handleError)
            {
                str = "";
            }
            return(str);
        }
コード例 #5
0
        internal string GetConnectAttrString(ODBC32.SQL_ATTR attribute)
        {
            string str2     = "";
            int    cbActual = 0;

            byte[] buffer = new byte[100];
            OdbcConnectionHandle connectionHandle = this.ConnectionHandle;

            if (connectionHandle != null)
            {
                ODBC32.RetCode code = connectionHandle.GetConnectionAttribute(attribute, buffer, out cbActual);
                if ((buffer.Length + 2) <= cbActual)
                {
                    buffer = new byte[cbActual + 2];
                    code   = connectionHandle.GetConnectionAttribute(attribute, buffer, out cbActual);
                }
                if ((code == ODBC32.RetCode.SUCCESS) || (ODBC32.RetCode.SUCCESS_WITH_INFO == code))
                {
                    return(Encoding.Unicode.GetString(buffer, 0, Math.Min(cbActual, buffer.Length)));
                }
                if (code != ODBC32.RetCode.ERROR)
                {
                    return(str2);
                }
                string diagSqlState = this.GetDiagSqlState();
                if ((!("HYC00" == diagSqlState) && !("HY092" == diagSqlState)) && !("IM001" == diagSqlState))
                {
                    return(str2);
                }
                this.FlagUnsupportedConnectAttr(attribute);
            }
            return(str2);
        }
コード例 #6
0
 internal OdbcTransaction(OdbcConnection connection, IsolationLevel isolevel, OdbcConnectionHandle handle) {
     OdbcConnection.VerifyExecutePermission();
     
     _connection = connection;
     _isolevel   = isolevel;
     _handle = handle;
 }
コード例 #7
0
        internal OdbcTransaction Open_BeginTransaction(System.Data.IsolationLevel isolevel)
        {
            ExecutePermission.Demand();
            this.CheckState("BeginTransaction");
            this.RollbackDeadTransaction();
            if ((this.weakTransaction != null) && this.weakTransaction.IsAlive)
            {
                throw ADP.ParallelTransactionsNotSupported(this);
            }
            switch (isolevel)
            {
            case System.Data.IsolationLevel.Unspecified:
            case System.Data.IsolationLevel.ReadUncommitted:
            case System.Data.IsolationLevel.ReadCommitted:
            case System.Data.IsolationLevel.RepeatableRead:
            case System.Data.IsolationLevel.Serializable:
            case System.Data.IsolationLevel.Snapshot:
            {
                OdbcConnectionHandle connectionHandle = this.ConnectionHandle;
                ODBC32.RetCode       retcode          = connectionHandle.BeginTransaction(ref isolevel);
                if (retcode == ODBC32.RetCode.ERROR)
                {
                    this.HandleError(connectionHandle, retcode);
                }
                OdbcTransaction target = new OdbcTransaction(this, isolevel, connectionHandle);
                this.weakTransaction = new WeakReference(target);
                return(target);
            }

            case System.Data.IsolationLevel.Chaos:
                throw ODBC.NotSupportedIsolationLevel(isolevel);
            }
            throw ADP.InvalidIsolationLevel(isolevel);
        }
コード例 #8
0
ファイル: OdbcConnection.cs プロジェクト: shangte/runtime
        internal string GetConnectAttrString(ODBC32.SQL_ATTR attribute)
        {
            string value    = "";
            int    cbActual = 0;

            byte[] buffer = new byte[100];
            OdbcConnectionHandle connectionHandle = ConnectionHandle;

            if (null != connectionHandle)
            {
                ODBC32.RetCode retcode = connectionHandle.GetConnectionAttribute(attribute, buffer, out cbActual);
                if (buffer.Length + 2 <= cbActual)
                {
                    // 2 bytes for unicode null-termination character
                    // retry with cbActual because original buffer was too small
                    buffer  = new byte[cbActual + 2];
                    retcode = connectionHandle.GetConnectionAttribute(attribute, buffer, out cbActual);
                }
                if ((ODBC32.RetCode.SUCCESS == retcode) || (ODBC32.RetCode.SUCCESS_WITH_INFO == retcode))
                {
                    value = (BitConverter.IsLittleEndian ? Encoding.Unicode : Encoding.BigEndianUnicode).GetString(buffer, 0, Math.Min(cbActual, buffer.Length));
                }
                else if (retcode == ODBC32.RetCode.ERROR)
                {
                    string sqlstate = GetDiagSqlState();
                    if (("HYC00" == sqlstate) || ("HY092" == sqlstate) || ("IM001" == sqlstate))
                    {
                        FlagUnsupportedConnectAttr(attribute);
                    }
                    // not throwing errors if not supported or other failure
                }
            }
            return(value);
        }
コード例 #9
0
ファイル: OdbcConnection.cs プロジェクト: shangte/runtime
        public override void Close()
        {
            InnerConnection.CloseConnection(this, ConnectionFactory);

            OdbcConnectionHandle connectionHandle = _connectionHandle;

            if (null != connectionHandle)
            {
                _connectionHandle = null;

                // If there is a pending transaction, automatically rollback.
                WeakReference weak = _weakTransaction;
                if (null != weak)
                {
                    _weakTransaction = null;
                    IDisposable transaction = weak.Target as OdbcTransaction;
                    if ((null != transaction) && weak.IsAlive)
                    {
                        transaction.Dispose();
                    }
                    // else transaction will be rolled back when handle is disposed
                }
                connectionHandle.Dispose();
            }
        }
コード例 #10
0
ファイル: OdbcConnection.cs プロジェクト: shangte/runtime
        internal int GetConnectAttr(ODBC32.SQL_ATTR attribute, ODBC32.HANDLER handler)
        {
            int retval   = -1;
            int cbActual = 0;

            byte[] buffer = new byte[4];
            OdbcConnectionHandle connectionHandle = ConnectionHandle;

            if (null != connectionHandle)
            {
                ODBC32.RetCode retcode = connectionHandle.GetConnectionAttribute(attribute, buffer, out cbActual);

                if ((ODBC32.RetCode.SUCCESS == retcode) || (ODBC32.RetCode.SUCCESS_WITH_INFO == retcode))
                {
                    retval = BitConverter.ToInt32(buffer, 0);
                }
                else
                {
                    if (retcode == ODBC32.RetCode.ERROR)
                    {
                        string sqlstate = GetDiagSqlState();
                        if (("HYC00" == sqlstate) || ("HY092" == sqlstate) || ("IM001" == sqlstate))
                        {
                            FlagUnsupportedConnectAttr(attribute);
                        }
                    }
                    if (handler == ODBC32.HANDLER.THROW)
                    {
                        this.HandleError(connectionHandle, retcode);
                    }
                }
            }
            return(retval);
        }
コード例 #11
0
ファイル: OdbcConnection.cs プロジェクト: shangte/runtime
        private string GetInfoStringUnhandled(ODBC32.SQL_INFO info, bool handleError)
        {
            //SQLGetInfo
            string value    = null;
            short  cbActual = 0;

            byte[] buffer = new byte[100];
            OdbcConnectionHandle connectionHandle = ConnectionHandle;

            if (null != connectionHandle)
            {
                ODBC32.RetCode retcode = connectionHandle.GetInfo2(info, buffer, out cbActual);
                if (buffer.Length < cbActual - 2)
                {
                    // 2 bytes for unicode null-termination character
                    // retry with cbActual because original buffer was too small
                    buffer  = new byte[cbActual + 2];
                    retcode = connectionHandle.GetInfo2(info, buffer, out cbActual);
                }
                if (retcode == ODBC32.RetCode.SUCCESS || retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)
                {
                    value = (BitConverter.IsLittleEndian ? Encoding.Unicode : Encoding.BigEndianUnicode).GetString(buffer, 0, Math.Min(cbActual, buffer.Length));
                }
                else if (handleError)
                {
                    this.HandleError(ConnectionHandle, retcode);
                }
            }
            else if (handleError)
            {
                value = "";
            }
            return(value);
        }
コード例 #12
0
ファイル: OdbcConnection.cs プロジェクト: shangte/runtime
        internal bool SQLGetFunctions(ODBC32.SQL_API odbcFunction)
        {
            //SQLGetFunctions
            ODBC32.RetCode retcode;
            short          fExists;

            Debug.Assert((short)odbcFunction != 0, "SQL_API_ALL_FUNCTIONS is not supported");
            OdbcConnectionHandle connectionHandle = ConnectionHandle;

            if (null != connectionHandle)
            {
                retcode = connectionHandle.GetFunctions(odbcFunction, out fExists);
            }
            else
            {
                Debug.Fail("GetFunctions called and ConnectionHandle is null (connection is disposed?)");
                throw ODBC.ConnectionClosed();
            }

            if (retcode != ODBC32.RetCode.SUCCESS)
            {
                this.HandleError(connectionHandle, retcode);
            }

            if (fExists == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #13
0
ファイル: OdbcTransaction.cs プロジェクト: vhatuncev/corefx
        public override void Commit()
        {
            OdbcConnection connection = _connection;

            if (null == connection)
            {
                throw ADP.TransactionZombied(this);
            }

            connection.CheckState(ADP.CommitTransaction); // MDAC 68289

            //Note: SQLEndTran success if not actually in a transaction, so we have to throw
            //since the IDbTransaciton spec indicates this is an error for the managed packages
            if (null == _handle)
            {
                throw ODBC.NotInTransaction();
            }

            ODBC32.RetCode retcode = _handle.CompleteTransaction(ODBC32.SQL_COMMIT);
            if (retcode == ODBC32.RetCode.ERROR)
            {
                //If an error has occurred, we will throw an exception in HandleError,
                //and leave the transaction active for the user to retry
                connection.HandleError(_handle, retcode);
            }

            //Transaction is complete...
            connection.LocalTransaction = null;
            _connection = null;
            _handle     = null;
        }
コード例 #14
0
ファイル: OdbcConnection.cs プロジェクト: shangte/runtime
        internal void Open_ChangeDatabase(string value)
        {
            CheckState(ADP.ChangeDatabase);

            // Database name must not be null, empty or whitspace
            if ((null == value) || (0 == value.Trim().Length))
            { // MDAC 62679
                throw ADP.EmptyDatabaseName();
            }
            if (1024 < value.Length * 2 + 2)
            {
                throw ADP.DatabaseNameTooLong();
            }
            RollbackDeadTransaction();

            //Set the database
            OdbcConnectionHandle connectionHandle = ConnectionHandle;

            ODBC32.RetCode retcode = connectionHandle.SetConnectionAttribute3(ODBC32.SQL_ATTR.CURRENT_CATALOG, value, checked ((int)value.Length * 2));

            if (retcode != ODBC32.RetCode.SUCCESS)
            {
                HandleError(connectionHandle, retcode);
            }
        }
コード例 #15
0
ファイル: OdbcTransaction.cs プロジェクト: dox0/DotNet471RS3
        internal OdbcTransaction(OdbcConnection connection, IsolationLevel isolevel, OdbcConnectionHandle handle)
        {
            OdbcConnection.VerifyExecutePermission();

            _connection = connection;
            _isolevel   = isolevel;
            _handle     = handle;
        }
コード例 #16
0
ファイル: OdbcConnection.cs プロジェクト: shangte/runtime
        private string GetDiagSqlState()
        {
            OdbcConnectionHandle connectionHandle = ConnectionHandle;
            string sqlstate;

            connectionHandle.GetDiagnosticField(out sqlstate);
            return(sqlstate);
        }
コード例 #17
0
        internal OdbcTransaction Open_BeginTransaction(IsolationLevel isolevel)
        {
            OdbcConnection.ExecutePermission.Demand();

            CheckState(ADP.BeginTransaction); // MDAC 68323

            RollbackDeadTransaction();

            if ((null != this.weakTransaction) && this.weakTransaction.IsAlive)   // regression from Dispose/Finalize work
            {
                throw ADP.ParallelTransactionsNotSupported(this);
            }

            //Use the default for unspecified.
            switch (isolevel)
            {
            case IsolationLevel.Unspecified:
            case IsolationLevel.ReadUncommitted:
            case IsolationLevel.ReadCommitted:
            case IsolationLevel.RepeatableRead:
            case IsolationLevel.Serializable:
            case IsolationLevel.Snapshot:
                break;

            case IsolationLevel.Chaos:
                throw ODBC.NotSupportedIsolationLevel(isolevel);

            default:
                throw ADP.InvalidIsolationLevel(isolevel);
            }
            ;

            //Start the transaction
            OdbcConnectionHandle connectionHandle = ConnectionHandle;

            ODBC32.RetCode retcode = connectionHandle.BeginTransaction(ref isolevel);
            if (retcode == ODBC32.RetCode.ERROR)
            {
                HandleError(connectionHandle, retcode);
            }
            OdbcTransaction transaction = new OdbcTransaction(this, isolevel, connectionHandle);

            this.weakTransaction = new WeakReference(transaction); // MDAC 69188
            return(transaction);
        }
コード例 #18
0
ファイル: OdbcTransaction.cs プロジェクト: vhatuncev/corefx
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         OdbcConnectionHandle handle = _handle;
         _handle = null;
         if (null != handle)
         {
             try
             {
                 ODBC32.RetCode retcode = handle.CompleteTransaction(ODBC32.SQL_ROLLBACK);
                 if (retcode == ODBC32.RetCode.ERROR)
                 {
                     //don't throw an exception here, but trace it so it can be logged
                     if (_connection != null)
                     {
                         Exception e = _connection.HandleErrorNoThrow(handle, retcode);
                         ADP.TraceExceptionWithoutRethrow(e);
                     }
                 }
             }
             catch (Exception e)
             {
                 //
                 if (!ADP.IsCatchableExceptionType(e))
                 {
                     throw;
                 }
             }
         }
         if (_connection != null)
         {
             if (_connection.IsOpen)
             {
                 _connection.LocalTransaction = null;
             }
         }
         _connection = null;
         _isolevel   = IsolationLevel.Unspecified;
     }
     base.Dispose(disposing);
 }
コード例 #19
0
        internal bool SQLGetFunctions(ODBC32.SQL_API odbcFunction)
        {
            short num;
            OdbcConnectionHandle connectionHandle = this.ConnectionHandle;

            if (connectionHandle == null)
            {
                throw ADP.InvalidOperation("what is the right exception to throw here?");
            }
            ODBC32.RetCode functions = connectionHandle.GetFunctions(odbcFunction, out num);
            if (functions != ODBC32.RetCode.SUCCESS)
            {
                this.HandleError(connectionHandle, functions);
            }
            if (num == 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #20
0
        public override void Close()
        {
            this.InnerConnection.CloseConnection(this, this.ConnectionFactory);
            OdbcConnectionHandle handle = this._connectionHandle;

            if (handle != null)
            {
                this._connectionHandle = null;
                WeakReference weakTransaction = this.weakTransaction;
                if (weakTransaction != null)
                {
                    this.weakTransaction = null;
                    IDisposable target = weakTransaction.Target as OdbcTransaction;
                    if ((target != null) && weakTransaction.IsAlive)
                    {
                        target.Dispose();
                    }
                }
                handle.Dispose();
            }
        }
コード例 #21
0
        internal void Open_ChangeDatabase(string value)
        {
            ExecutePermission.Demand();
            this.CheckState("ChangeDatabase");
            if ((value == null) || (value.Trim().Length == 0))
            {
                throw ADP.EmptyDatabaseName();
            }
            if (0x400 < ((value.Length * 2) + 2))
            {
                throw ADP.DatabaseNameTooLong();
            }
            this.RollbackDeadTransaction();
            OdbcConnectionHandle connectionHandle = this.ConnectionHandle;

            ODBC32.RetCode retcode = connectionHandle.SetConnectionAttribute3(ODBC32.SQL_ATTR.CURRENT_CATALOG, value, value.Length * 2);
            if (retcode != ODBC32.RetCode.SUCCESS)
            {
                this.HandleError(connectionHandle, retcode);
            }
        }
コード例 #22
0
 public override void Commit()
 {
     OdbcConnection.ExecutePermission.Demand();
     OdbcConnection connection = this._connection;
     if (connection == null)
     {
         throw ADP.TransactionZombied(this);
     }
     connection.CheckState("CommitTransaction");
     if (this._handle == null)
     {
         throw ODBC.NotInTransaction();
     }
     ODBC32.RetCode retcode = this._handle.CompleteTransaction(0);
     if (retcode == ODBC32.RetCode.ERROR)
     {
         connection.HandleError(this._handle, retcode);
     }
     connection.LocalTransaction = null;
     this._connection = null;
     this._handle = null;
 }
コード例 #23
0
        public override void Rollback()
        {
            OdbcConnection connection = this._connection;

            if (connection == null)
            {
                throw ADP.TransactionZombied(this);
            }
            connection.CheckState("RollbackTransaction");
            if (this._handle == null)
            {
                throw ODBC.NotInTransaction();
            }
            ODBC32.RetCode retcode = this._handle.CompleteTransaction(1);
            if (retcode == ODBC32.RetCode.ERROR)
            {
                connection.HandleError(this._handle, retcode);
            }
            connection.LocalTransaction = null;
            this._connection            = null;
            this._handle = null;
        }
コード例 #24
0
        public override void Commit()
        {
            OdbcConnection.ExecutePermission.Demand();
            OdbcConnection connection = this._connection;

            if (connection == null)
            {
                throw ADP.TransactionZombied(this);
            }
            connection.CheckState("CommitTransaction");
            if (this._handle == null)
            {
                throw ODBC.NotInTransaction();
            }
            ODBC32.RetCode retcode = this._handle.CompleteTransaction(0);
            if (retcode == ODBC32.RetCode.ERROR)
            {
                connection.HandleError(this._handle, retcode);
            }
            connection.LocalTransaction = null;
            this._connection            = null;
            this._handle = null;
        }
コード例 #25
0
        internal void Open_EnlistTransaction(Transaction transaction)
        {
            ODBC32.RetCode code;
            if ((this.weakTransaction != null) && this.weakTransaction.IsAlive)
            {
                throw ADP.LocalTransactionPresent();
            }
            IDtcTransaction      oletxTransaction = ADP.GetOletxTransaction(transaction);
            OdbcConnectionHandle connectionHandle = this.ConnectionHandle;

            if (oletxTransaction == null)
            {
                code = connectionHandle.SetConnectionAttribute2(ODBC32.SQL_ATTR.SQL_COPT_SS_ENLIST_IN_DTC, IntPtr.Zero, 1);
            }
            else
            {
                code = connectionHandle.SetConnectionAttribute4(ODBC32.SQL_ATTR.SQL_COPT_SS_ENLIST_IN_DTC, oletxTransaction, 1);
            }
            if (code != ODBC32.RetCode.SUCCESS)
            {
                this.HandleError(connectionHandle, code);
            }
            ((OdbcConnectionOpen)this.InnerConnection).EnlistedTransaction = transaction;
        }
コード例 #26
0
 public override void Rollback()
 {
     OdbcConnection connection = this._connection;
     if (connection == null)
     {
         throw ADP.TransactionZombied(this);
     }
     connection.CheckState("RollbackTransaction");
     if (this._handle == null)
     {
         throw ODBC.NotInTransaction();
     }
     ODBC32.RetCode retcode = this._handle.CompleteTransaction(1);
     if (retcode == ODBC32.RetCode.ERROR)
     {
         connection.HandleError(this._handle, retcode);
     }
     connection.LocalTransaction = null;
     this._connection = null;
     this._handle = null;
 }
コード例 #27
0
ファイル: OdbcTransaction.cs プロジェクト: vhatuncev/corefx
 internal OdbcTransaction(OdbcConnection connection, IsolationLevel isolevel, OdbcConnectionHandle handle)
 {
     _connection = connection;
     _isolevel   = isolevel;
     _handle     = handle;
 }
 internal static extern ODBC32.RetCode SQLGetConnectAttrW(OdbcConnectionHandle ConnectionHandle, ODBC32.SQL_ATTR Attribute, byte[] Value, int BufferLength, out int StringLength);
 internal static extern ODBC32.RetCode SQLGetInfoW(OdbcConnectionHandle hdbc, ODBC32.SQL_INFO fInfoType, byte[] rgbInfoValue, short cbInfoValueMax, IntPtr pcbInfoValue);
コード例 #30
0
 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLDriverConnectW(
     /*SQLHDBC*/OdbcConnectionHandle hdbc,
     /*SQLHWND*/IntPtr hwnd,
     [In, MarshalAs(UnmanagedType.LPWStr)]
     /*SQLCHAR* */string               connectionstring,
     /*SQLSMALLINT*/Int16            cbConnectionstring,
     /*SQLCHAR* */IntPtr               connectionstringout,
     /*SQLSMALLINT*/Int16            cbConnectionstringoutMax,
     /*SQLSMALLINT* */out Int16        cbConnectionstringout,
     /*SQLUSMALLINT*/Int16           fDriverCompletion);
コード例 #31
0
        override public void Commit() {
            OdbcConnection.ExecutePermission.Demand(); // MDAC 81476

            OdbcConnection connection = _connection;
            if (null == connection) {
                throw ADP.TransactionZombied(this);
            }

            connection.CheckState(ADP.CommitTransaction); // MDAC 68289

            //Note: SQLEndTran success if not actually in a transaction, so we have to throw
            //since the IDbTransaciton spec indicates this is an error for the managed packages
            if(null == _handle) {
                throw ODBC.NotInTransaction();
            }
            
            ODBC32.RetCode retcode = _handle.CompleteTransaction(ODBC32.SQL_COMMIT);
            if (retcode == ODBC32.RetCode.ERROR)  {
                //If an error has occurred, we will throw an exception in HandleError,
                //and leave the transaction active for the user to retry
                connection.HandleError(_handle, retcode);
            }

            //Transaction is complete...
            connection.LocalTransaction = null;
            _connection = null;
            _handle = null;
            
        }
コード例 #32
0
 protected override void Dispose(bool disposing) {
     if (disposing) {
         OdbcConnectionHandle handle = _handle;
         _handle = null;
         if (null != handle){
             try{
                 ODBC32.RetCode retcode = handle.CompleteTransaction(ODBC32.SQL_ROLLBACK);
                 if (retcode == ODBC32.RetCode.ERROR) {
                     //don't throw an exception here, but trace it so it can be logged
                     if (_connection != null) {
                         Exception e = _connection.HandleErrorNoThrow(handle, retcode);
                         ADP.TraceExceptionWithoutRethrow(e);                               
                     }
                 }
             }
             catch (Exception e){
                 // 
                 if (!ADP.IsCatchableExceptionType(e)) {
                     throw;
                 }
             }
         }
         if (_connection != null) {
             if (_connection.IsOpen) {
                 _connection.LocalTransaction = null;
             }
         }
         _connection = null;
         _isolevel = IsolationLevel.Unspecified;
     }
     base.Dispose(disposing);
 }
コード例 #33
0
 internal OdbcTransaction(OdbcConnection connection, System.Data.IsolationLevel isolevel, OdbcConnectionHandle handle)
 {
     this._connection = connection;
     this._isolevel = isolevel;
     this._handle = handle;
 }
 internal static extern ODBC32.RetCode SQLDriverConnectW(OdbcConnectionHandle hdbc, IntPtr hwnd, [In, MarshalAs(UnmanagedType.LPWStr)] string connectionstring, short cbConnectionstring, IntPtr connectionstringout, short cbConnectionstringoutMax, out short cbConnectionstringout, short fDriverCompletion);
コード例 #35
0
 internal OdbcStatementHandle(OdbcConnectionHandle connectionHandle) : base(ODBC32.SQL_HANDLE.STMT, connectionHandle) {
 }
コード例 #36
0
 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetFunctions(
     /*SQLHBDC*/OdbcConnectionHandle hdbc,
     /*SQLUSMALLINT*/ODBC32.SQL_API fFunction,
     /*SQLUSMALLINT* */out Int16 pfExists);
コード例 #37
0
 internal OdbcStatementHandle(OdbcConnectionHandle connectionHandle) : base(ODBC32.SQL_HANDLE.STMT, connectionHandle)
 {
 }
コード例 #38
0
 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetConnectAttrW(
     /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle,
     /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute,
     /*SQLPOINTER*/byte[] Value,
     /*SQLINTEGER*/Int32 BufferLength,
     /*SQLINTEGER* */out Int32 StringLength);
コード例 #39
0
 internal OdbcTransaction(OdbcConnection connection, System.Data.IsolationLevel isolevel, OdbcConnectionHandle handle)
 {
     this._connection = connection;
     this._isolevel   = isolevel;
     this._handle     = handle;
 }
コード例 #40
0
 public override void Close()
 {
     this.InnerConnection.CloseConnection(this, this.ConnectionFactory);
     OdbcConnectionHandle handle = this._connectionHandle;
     if (handle != null)
     {
         this._connectionHandle = null;
         WeakReference weakTransaction = this.weakTransaction;
         if (weakTransaction != null)
         {
             this.weakTransaction = null;
             IDisposable target = weakTransaction.Target as OdbcTransaction;
             if ((target != null) && weakTransaction.IsAlive)
             {
                 target.Dispose();
             }
         }
         handle.Dispose();
     }
 }
コード例 #41
0
 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW(
     /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle,
     /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute,
     /*SQLPOINTER*/IntPtr Value,
     /*SQLINTEGER*/Int32 StringLength);
 internal static extern ODBC32.RetCode SQLGetFunctions(OdbcConnectionHandle hdbc, ODBC32.SQL_API fFunction, out short pfExists);
コード例 #43
0
 static internal extern /*SQLRETURN*/ODBC32.RetCode SQLGetInfoW(
     /*SQLHBDC*/OdbcConnectionHandle hdbc,
     /*SQLUSMALLINT*/ODBC32.SQL_INFO fInfoType,
     /*SQLPOINTER*/byte[] rgbInfoValue,
     /*SQLSMALLINT*/Int16 cbInfoValueMax,
     /*SQLSMALLINT* */IntPtr pcbInfoValue);
 internal static extern ODBC32.RetCode SQLSetConnectAttrW(OdbcConnectionHandle ConnectionHandle, ODBC32.SQL_ATTR Attribute, IDtcTransaction Value, int StringLength);
コード例 #45
0
        override public void Close() {
            InnerConnection.CloseConnection(this, ConnectionFactory);

            OdbcConnectionHandle connectionHandle = _connectionHandle;

            if (null != connectionHandle) {
                _connectionHandle = null;

                // If there is a pending transaction, automatically rollback.
                WeakReference weak = this.weakTransaction;
                if (null != weak) {
                    this.weakTransaction = null;
                    IDisposable transaction = weak.Target as OdbcTransaction;
                    if ((null != transaction) && weak.IsAlive) {
                        transaction.Dispose();
                    }
                    // else transaction will be rolled back when handle is disposed
                }
                connectionHandle.Dispose();
            }
        }