示例#1
0
        void Close()
        {
            if (transaction != null && transaction.IsOpen)
            {
                transaction.Rollback();
            }

            if (dataReader != null)
            {
                if (tds != null)
                {
                    tds.SkipToEnd();
                }
                dataReader = null;
            }

            if (tds != null && tds.IsConnected)
            {
                if (pooling && tds.Pooling)
                {
                    if (pool != null)
                    {
                        pool.ReleaseConnection(tds);
                    }
                }
                else
                if (tds != null)
                {
                    tds.Disconnect();
                }
            }

            if (tds != null)
            {
                tds.TdsErrorMessage -= new TdsInternalErrorMessageEventHandler(ErrorHandler);
                tds.TdsInfoMessage  -= new TdsInternalInfoMessageEventHandler(MessageHandler);
            }

            ChangeState(ConnectionState.Closed);
        }