本文整理汇总了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();
}
示例2: ReleaseServerConnection
public void ReleaseServerConnection(IDbConnection dbConnection)
{
if (dbConnection == null)
return;
if (dbConnection.State != ConnectionState.Closed)
dbConnection.Close();
dbConnection.Dispose();
}
示例3: OnDisposeConnection
protected virtual void OnDisposeConnection( IDbConnection connection )
{
if( connection != null )
{
if( connection.State == ConnectionState.Open )
{
connection.Close();
}
connection.Dispose();
}
}
示例4: Close
public bool Close(IDbConnection c)
{
try
{
c.Dispose();
c = null;
return true;
}
catch
{
return false;
}
}
示例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();
}
}
}
示例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;
}
}
示例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;
}
示例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();
}
示例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);
}
示例10: initDatabase
public virtual void initDatabase(IDbConnection db)
{
db.Dispose ();
}
示例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));
}
}
示例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();
}
}
示例13: DisposeConnection
public static void DisposeConnection(IDbConnection conn)
{
conn.Close();
conn.Dispose();
}
示例14: CloseConnection
public void CloseConnection(IDbConnection conn)
{
if (conn != null && conn.State != ConnectionState.Closed)
{
conn.Close();
conn.Dispose();
}
}
示例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);
}