Esempio n. 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);
        }
Esempio n. 2
0
 /// <summary>
 /// 打开连接
 /// </summary>
 public void Open()
 {
     if (!connection.IsOpen)
     {
         connection.Open();
     }
     isOpen = true;
 }