コード例 #1
0
        // Get the Descriptor Handle for the current statement
        //
        internal HandleRef GetDescriptorHandle()
        {
            if (_hdesc != IntPtr.Zero)
            {
                return(new HandleRef(this, _hdesc));
            }
            Debug.Assert((_cmdWrapper != null), "Must have the wrapper object!");
            Debug.Assert((_cmdWrapper._stmt != IntPtr.Zero), "Must have statement handle when calling GetDescriptorHandle");
            Debug.Assert((_cmdWrapper._dataReaderBuf != null), "Must have dataReader buffer when calling GetDescriptorHandle");

            int cbActual = 0;   // Dummy value

            ODBC32.RETCODE retcode = (ODBC32.RETCODE)
                                     UnsafeNativeMethods.Odbc32.SQLGetStmtAttrW(
                _cmdWrapper,
                (int)ODBC32.SQL_ATTR.APP_PARAM_DESC,
                _cmdWrapper._dataReaderBuf,
                IntPtr.Size,
                out cbActual);


            if (ODBC32.RETCODE.SUCCESS != retcode)
            {
                _connection.HandleError(_cmdWrapper, ODBC32.SQL_HANDLE.STMT, retcode);
            }
            _hdesc = Marshal.ReadIntPtr(_cmdWrapper._dataReaderBuf.Ptr, 0);
            return(new HandleRef(this, _hdesc));
        }
コード例 #2
0
        /*public OdbcCommand CreateCommand() { // MDAC 68309
         *  OdbcCommand cmd = Connection.CreateCommand();
         *  cmd.Transaction = this;
         *  return cmd;
         * }
         *
         * IDbCommand IDbTransaction.CreateCommand() {
         *  return CreateCommand();
         * }*/

        /// <include file='doc\OdbcTransaction.uex' path='docs/doc[@for="OdbcTransaction.Commit"]/*' />
        public void Commit()
        {
            OdbcConnection.OdbcPermission.Demand(); // MDAC 81476

            if (null == this.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 (AutoCommit)
            {
                throw ODC.NotInTransaction();
            }

            //Commit the transaction (for just this connection)
            ODBC32.RETCODE retcode = (ODBC32.RETCODE)
                                     UnsafeNativeMethods.Odbc32.SQLEndTran(
                (short)ODBC32.SQL_HANDLE.DBC,
                this.connection._dbcWrapper,
                (Int16)ODBC32.SQL_TXN.COMMIT);
            if (retcode != ODBC32.RETCODE.SUCCESS)
            {
                this.connection.HandleError(this.connection._dbcWrapper, ODBC32.SQL_HANDLE.DBC, retcode);
            }

            //Transaction is complete...
            AutoCommit = true;
            this.connection.weakTransaction = null;
            this.connection._dbcWrapper._isInTransaction = false;
            this.connection = null;
        }
コード例 #3
0
 private OdbcException(SerializationInfo si, StreamingContext sc) : base(si, sc)
 {
     this.odbcErrors = new OdbcErrorCollection();
     this._retcode   = (ODBC32.RETCODE)si.GetValue("odbcRetcode", typeof(ODBC32.RETCODE));
     this.odbcErrors = (OdbcErrorCollection)si.GetValue("odbcErrors", typeof(OdbcErrorCollection));
     base.HResult    = -2146232009;
 }
コード例 #4
0
 private OdbcException(SerializationInfo si, StreamingContext sc) : base(si, sc)
 {
     this.odbcErrors = new OdbcErrorCollection();
     this._retcode = (ODBC32.RETCODE) si.GetValue("odbcRetcode", typeof(ODBC32.RETCODE));
     this.odbcErrors = (OdbcErrorCollection) si.GetValue("odbcErrors", typeof(OdbcErrorCollection));
     base.HResult = -2146232009;
 }
コード例 #5
0
        /// <include file='doc\OdbcTransaction.uex' path='docs/doc[@for="OdbcTransaction.Rollback"]/*' />
        public void Rollback()
        {
            if (null == this.connection)
            {
                throw ADP.TransactionZombied(this);
            }
            connection.CheckState(ADP.RollbackTransaction); // 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 (AutoCommit)
            {
                throw ODC.NotInTransaction();
            }

            try { // try-finally inside try-catch-throw
                try {
                    //Abort the transaction (for just this connection)
                    ODBC32.RETCODE retcode = (ODBC32.RETCODE)
                                             UnsafeNativeMethods.Odbc32.SQLEndTran(
                        (short)ODBC32.SQL_HANDLE.DBC,
                        this.connection._dbcWrapper,
                        (Int16)ODBC32.SQL_TXN.ROLLBACK);
                    if (retcode != ODBC32.RETCODE.SUCCESS)
                    {
                        this.connection.HandleError(this.connection._dbcWrapper, ODBC32.SQL_HANDLE.DBC, retcode);
                    }

                    //Transaction is complete...
                    AutoCommit = true;
                }
                finally {
                    this.connection.weakTransaction = null;
                    this.connection._dbcWrapper._isInTransaction = false;
                    this.connection = null;
                }
            }
            catch { // MDAC 81875
                throw;
            }
        }
コード例 #6
0
 // runtime will call even if private...
 // <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity />
 private OdbcException(SerializationInfo si, StreamingContext sc) : base(si, sc)
 {
     _retcode   = (ODBC32.RETCODE)si.GetValue("odbcRetcode", typeof(ODBC32.RETCODE));
     odbcErrors = (OdbcErrorCollection)si.GetValue("odbcErrors", typeof(OdbcErrorCollection));
 }
コード例 #7
0
 internal OdbcException(OdbcErrorCollection errors, ODBC32.RETCODE retcode)
 {
     odbcErrors = errors;
     _retcode   = retcode;
 }
コード例 #8
0
 static internal Exception CantAllocateEnvironmentHandle(ODBC32.RETCODE retcode)
 {
     return(DataProvider(Res.GetString(GetCultureInfo(), Res.Odbc_CantAllocateEnvironmentHandle, retcode.ToString())));
 }
コード例 #9
0
 static internal Exception CantEnableConnectionpooling(ODBC32.RETCODE retcode)
 {
     return(DataProvider(Res.GetString(GetCultureInfo(), Res.Odbc_CantEnableConnectionpooling, retcode.ToString())));
 }
コード例 #10
0
ファイル: OdbcException.cs プロジェクト: uQr/referencesource
 // runtime will call even if private...
 private OdbcException(SerializationInfo si, StreamingContext sc) : base(si, sc) {
     _retcode = (ODBC32.RETCODE) si.GetValue("odbcRetcode", typeof(ODBC32.RETCODE));
     odbcErrors = (OdbcErrorCollection) si.GetValue("odbcErrors", typeof(OdbcErrorCollection));
     HResult = HResults.OdbcException;
 }