Exemple #1
0
 public override void Open()
 {
     IntPtr ptr;
     Bid.ScopeEnter(out ptr, "<sc.SqlConnection.Open|API> %d#", this.ObjectID);
     try
     {
         if (this.StatisticsEnabled)
         {
             if (this._statistics == null)
             {
                 this._statistics = new SqlStatistics();
             }
             else
             {
                 this._statistics.ContinueOnNewConnection();
             }
         }
         SNIHandle target = null;
         SqlStatistics statistics = null;
         RuntimeHelpers.PrepareConstrainedRegions();
         try
         {
             statistics = SqlStatistics.StartTimer(this.Statistics);
             this.InnerConnection.OpenConnection(this, this.ConnectionFactory);
             target = SqlInternalConnection.GetBestEffortCleanupTarget(this);
             SqlInternalConnectionSmi innerConnection = this.InnerConnection as SqlInternalConnectionSmi;
             if (innerConnection != null)
             {
                 innerConnection.AutomaticEnlistment();
             }
             else
             {
                 if (this.StatisticsEnabled)
                 {
                     ADP.TimerCurrent(out this._statistics._openTimestamp);
                     this.Parser.Statistics = this._statistics;
                 }
                 else
                 {
                     this.Parser.Statistics = null;
                     this._statistics = null;
                 }
                 this.CompleteOpen();
             }
         }
         catch (OutOfMemoryException exception3)
         {
             this.Abort(exception3);
             throw;
         }
         catch (StackOverflowException exception2)
         {
             this.Abort(exception2);
             throw;
         }
         catch (ThreadAbortException exception)
         {
             this.Abort(exception);
             SqlInternalConnection.BestEffortCleanup(target);
             throw;
         }
         finally
         {
             SqlStatistics.StopTimer(statistics);
         }
     }
     finally
     {
         Bid.ScopeLeave(ref ptr);
     }
 }