Beispiel #1
0
        private IDbConnection OpenConnection()
        {
            try
            {
                if (m_openConnectionCount > m_maxOpenConnections)
                {
                    throw new Exception("Open Connections is at " + m_openConnectionCount);
                }

                IDbConnection connection = m_factory.CreateConnection(m_connectionString);
                connection.Open();
                ++m_openConnectionCount;
                return(connection);
            }
            catch (Exception e)
            {
                Debug.WriteLine(String.Format("There are {0} connections open at the moment", m_openConnectionCount));
                Exception innerE = e.GetBaseException();
                Debug.WriteLine(String.Format("Exception message was \"{0}\"", innerE.Message));
                Debug.WriteLine(String.Format("Exception stacktrace was \"{0}\"", innerE.StackTrace));

                throw;
            }
        }