protected virtual void Dispose(bool disposing) { if (!m_disposed) { if (disposing) { // 释放托管代码 if (DBTrans != null) { DBTrans.Dispose(); DBTrans = null; } if (DBConn != null) { if (DBConn.State == ConnectionState.Open) { DBConn.Close(); } DBConn.Dispose(); DBConn = null; } } //释放非托管代码 m_disposed = true; } }
/// <summary> /// 提交数据库操作 /// </summary> protected void Commit() { if (this.DBTrans != null) { DBTrans.Commit(); DBTrans.Dispose(); DBTrans = null; } if (DBConn.State == ConnectionState.Open) { DBConn.Close(); } DBConn.Dispose(); DBConn = null; }