Пример #1
0
        public override void Open()
        {
            if (state == ConnectionState.Open)
            {
                throw new InvalidOperationException("The Connection is already Open (State=Open)");
            }

            if (connectionString == null || connectionString.Trim().Length == 0)
            {
                throw new InvalidOperationException("Connection string has not been initialized.");
            }

            connection = TdsConnectionPool.GetConnection(dataSource, port, deviceId, priority, timeout);

            try
            {
                connection.Open();
            }
            catch (SocketException se)
            {
                throw new DbProxyException(se.Message, se);
            }

            disposed = false; // reset this, so using () would call Close ().
            ChangeState(ConnectionState.Open);
        }
Пример #2
0
 /// <summary>
 /// 关闭连接
 /// </summary>
 public void Close()
 {
     if (isOpen)
     {
         isOpen = false;
         TdsConnectionPool.PutConnection(connection);
     }
 }