当前位置: 首页>>代码示例>>C#>>正文


C# IDbConnection.Dispose方法代码示例

本文整理汇总了C#中IDbConnection.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# IDbConnection.Dispose方法的具体用法?C# IDbConnection.Dispose怎么用?C# IDbConnection.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDbConnection的用法示例。


在下文中一共展示了IDbConnection.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReleaseClientConnection

        public virtual void ReleaseClientConnection(IDbConnection dbConnection)
        {
            if (dbConnection == null)
                return;

            dbConnection.Close();
            dbConnection.Dispose();
        }
开发者ID:ovuncgursoy,项目名称:SisoDb-Provider,代码行数:8,代码来源:SqlServerConnectionManager.cs

示例2: ReleaseServerConnection

		public void ReleaseServerConnection(IDbConnection dbConnection)
		{
			if (dbConnection == null)
				return;

			if (dbConnection.State != ConnectionState.Closed)
				dbConnection.Close();

			dbConnection.Dispose();
		}
开发者ID:BlackMael,项目名称:SisoDb-Provider,代码行数:10,代码来源:SqlCe4ConnectionManager.cs

示例3: OnDisposeConnection

		protected virtual void OnDisposeConnection( IDbConnection connection )
		{
			if( connection != null )
			{
				if( connection.State == ConnectionState.Open )
				{
					connection.Close();
				}

				connection.Dispose();
			}
		}
开发者ID:nazarenomanco,项目名称:Radical,代码行数:12,代码来源:DataCommand.cs

示例4: Close

 public bool Close(IDbConnection c)
 {
     try
     {
         c.Dispose();
         c = null;
         return true;
     }
     catch
     {
         return false;
     }
 }
开发者ID:nandyx,项目名称:ManageMyServer,代码行数:13,代码来源:Connection.cs

示例5: FinishTransaction

    protected void FinishTransaction(IDbConnection vConn, Boolean isPostRequest, SQLTransactionCmd cmd) {
      if (!isPostRequest) {
        if (vConn != null) {
          vConn.Close();
          vConn.Dispose();
        }
        return;
      }

      var vCommited = false;
      if (this.AutoCommitTransaction || (cmd == SQLTransactionCmd.Commit)) {
        vCommited = true;
        if (!String.IsNullOrEmpty(this.TransactionID))
          this.BioSession.Cfg.dbSession.StoreTransaction(this.TransactionID, null);
      } else if (cmd == SQLTransactionCmd.Rollback)
        this.BioSession.Cfg.dbSession.KillTransaction(this.TransactionID);
      if (vCommited || (cmd == SQLTransactionCmd.Rollback)) {
        if (vConn != null) {
          vConn.Close();
          vConn.Dispose();
        }
      }
    }
开发者ID:tormoz70,项目名称:Bio.Framework.8,代码行数:23,代码来源:ABioHandlerBioTransacted.cs

示例6: OpenConnection

        /// <summary>
        /// Opens an <see cref="IDbConnection"/> for the provided connection string..
        /// </summary>
        /// <param name="conn">The <see cref="IDbConnection"/> to open.</param>
        /// <param name="connectionString">The connection string.</param>
        public virtual void OpenConnection(IDbConnection conn, string connectionString)
        {
            try
            {
                conn.ConnectionString = connectionString;
                conn.Open();
            }
            catch (Exception)
            {
                conn.Dispose();
                throw;
            }

        }
开发者ID:prime,项目名称:nshibernate,代码行数:19,代码来源:ConnectionProvider.cs

示例7: CloseDbConnection

        /// <summary>
        ///  关闭MDB数据库
        /// </summary>
        /// <param name="pAdoConn"></param>
        /// <returns></returns>
        public static bool CloseDbConnection(IDbConnection pAdoConn)
        {
            try
            {
                if (pAdoConn != null && pAdoConn.State != null)
                {
                    pAdoConn.Close();
                    pAdoConn.Dispose();
                    GC.Collect();
                }
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                return false;
            }
            return true;
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:24,代码来源:AdoDbHelper.cs

示例8: DoDisposeConnection

        private static void DoDisposeConnection(IDbConnection conn, IDbProvider dbProvider)
        {
            if (conn == null)
            {
                return;
            }

            if (dbProvider != null)
            {
                ConnectionHolder conHolder = (ConnectionHolder)TransactionSynchronizationManager.GetResource(dbProvider);
                if (conHolder != null && ConnectionEquals(conHolder.Connection, conn))
                {
                    // It's the transactional connection bound to the thread so don't close it.
                    conHolder.Released();
                    return;
                }
            }
            if (LOG.IsDebugEnabled)
            {
                LOG.Debug("Disposing of IDbConnection with connection string = [" + dbProvider.ConnectionString + "]");
            }
            conn.Dispose();
        }
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:23,代码来源:ConnectionUtils.cs

示例9: ReleaseConnection

 public virtual void ReleaseConnection(IDbConnection cnx)
 {
     // if it's writable connection we keep it open
     // for transaction
     if (cnx == writableConnection)
         return;
     cnx.Close();
     cnx.Dispose();
     this.connections.Remove(cnx);
 }
开发者ID:kYann,项目名称:SqlReplicationClient,代码行数:10,代码来源:ReplicationConnection.cs

示例10: initDatabase

 public virtual void initDatabase(IDbConnection db)
 {
     db.Dispose ();
 }
开发者ID:ttwj,项目名称:dreamskape,代码行数:4,代码来源:ModulePlugin.cs

示例11: CloseConnection

        static void CloseConnection(IDbConnection conn)
        {
            if (conn == null)
            {
                Debug.Fail("conn is null.");
                return;
            }

            try
            {
                conn.Close();
                conn.Dispose();
            }
            catch (ObjectDisposedException)
            {
                const string errmsg = "Connection `{0}` already disposed.";
                if (log.IsDebugEnabled)
                    log.DebugFormat(errmsg, conn);
            }
            catch (Exception ex)
            {
                const string errmsg = "Failed to dispose `{0}`. Exception: {1}";
                if (log.IsErrorEnabled)
                    log.ErrorFormat(errmsg, conn, ex);
                Debug.Fail(string.Format(errmsg, conn, ex));
            }
        }
开发者ID:wtfcolt,项目名称:game,代码行数:27,代码来源:SchemaReader.cs

示例12: CloseDBConnection

        /// <summary>
        /// Closes a DB connection. Also calls the <c>Dispose()</c> Method on the DB connection object.
        /// </summary>
        /// <remarks>
        /// Although the .NET FCL allows the <see cref="IDbConnection.Close" /> method to be
        /// called even on already closed connections without causing an error,
        /// for the purposes of cleaner application development this method throws
        /// an exception when the caller tries to close an already/still closed
        /// connection.
        /// </remarks>
        /// <param name="AConnection">Open Database connection</param>
        /// <returns>void</returns>
        /// <exception cref="EDBConnectionAlreadyClosedException">When trying to close an
        /// already/still closed DB connection.</exception>
        public void CloseDBConnection(IDbConnection AConnection)
        {
            if (AConnection == null)
            {
                throw new ArgumentNullException("AConnection", "AConnection must not be null!");
            }

            if (AConnection.State != ConnectionState.Closed)
            {
                try
                {
                    AConnection.Close();
                    AConnection.Dispose();

                    // TLogging.Log("Database connection closed.");
                }
                catch (Exception exp)
                {
                    TLogging.Log("Error closing Database connection!" + "Exception: " + exp.ToString());
                    throw;
                }
            }
            else
            {
                throw new EDBConnectionAlreadyClosedException();
            }
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:41,代码来源:Connection.cs

示例13: DisposeConnection

 public static void DisposeConnection(IDbConnection conn)
 {
     conn.Close();
     conn.Dispose();
 }
开发者ID:TaylorLi,项目名称:gettogether,代码行数:5,代码来源:ConnectionHelper.cs

示例14: CloseConnection

 public void CloseConnection(IDbConnection conn)
 {
     if (conn != null && conn.State != ConnectionState.Closed)
     {
         conn.Close();
         conn.Dispose();
     }
 }
开发者ID:dalinhuang,项目名称:myxx,代码行数:8,代码来源:DataBase.cs

示例15: MenuUtama

        public MenuUtama(IDbConnection conn)
        {
            InitializeComponent();
            _conn = conn;

            DAL shipper = null;
            IDataReader reader = null;
            current = DateTime.Now;

            try
            {
                shipper = new DAL();
                reader = shipper.Cek_Sales(_conn);

                if (reader.Read())
                {
                    Hide();
                    using (Login l = new Login(_conn)) //if data ok, form will close it self!
                    {
                        if (l.ShowDialog() == DialogResult.OK)
                        {
                            this.Visible = true;
                        }
                        else
                        {
                            _conn.Close();
                            _conn.Dispose();
                            Application.Exit();
                        }
                    }
                }
                else
                {
                    Hide();
                    using (Register c = new Register(_conn)) //if data ok, form will close it self!
                    {
                        if (c.ShowDialog() == DialogResult.OK)
                        {
                            this.Visible = true;
                        }
                        else
                        {
                            _conn.Close();
                            _conn.Dispose();
                            Application.Exit();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                    reader.Dispose();
                }
            }
            retrieve_salesData();
            retrieve_pageData(current);
        }
开发者ID:yuddis,项目名称:ToyotaReminderApp,代码行数:64,代码来源:MenuUtama.cs


注:本文中的IDbConnection.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。