コード例 #1
0
        /// <summary>
        /// Releases the connection back to the connection pool.
        /// </summary>
        public void Close()
        {
            if (_socket != null)
            {
                MonetDbConnectionFactory.CloseConnection(_socket, Database);
            }

            _connectionState = ConnectionState.Closed;
        }
コード例 #2
0
        /// <summary>
        /// Opens a database connection with the settings specified by the <c>ConnectionString</c> property
        /// of the provider-specific Connection object.
        /// </summary>
        public void Open()
        {
            if (_connectionState == ConnectionState.Open)
            {
                throw new InvalidOperationException("Connection is already open");
            }

            _connectionState = ConnectionState.Connecting;

            if (string.IsNullOrEmpty(ConnectionString))
            {
                _connectionState = ConnectionState.Closed;
                throw new InvalidOperationException("ConnectionString has not been set.  Cannot connect to database.");
            }

            _socket = MonetDbConnectionFactory.GetConnection(_host, _port, _username, _password,
                                                             _dbname, _useSsl, _minPoolConnections, _maxPoolConnections);

            _connectionState = ConnectionState.Open;
        }