【文件属性】:
文件名称:C# oracle通用类
文件大小:3KB
文件格式:RAR
更新时间:2015-03-19 18:03:13
C# oracle 事务处理
C# oracle 类 事务处理
#region 公有方法
public void JoinTransaction(Transaction transaction)
{
if (this._transaction != null)
{
throw new Exception("对象已经在另一个事务中");
}
else
{
this._transaction = transaction.DataBaseTransaction;
}
}
public void QuitTransaction()
{
if (this._transaction != null)
{
// 确保_dataAdapter对象的各命令的连接不是事务的连接,以免Dispose _dataAdapter对象时,意外关闭事务的连接。
if (this._dataAdapter != null)
{
if (this._dataAdapter.SelectCommand != null)
{
if (this._dataAdapter.SelectCommand.Connection != null)
if (this._dataAdapter.SelectCommand.Connection.Equals(this._transaction.Connection))
this._dataAdapter.SelectCommand.Connection = null;
}
if (this._dataAdapter.InsertCommand != null)
{
if (this._dataAdapter.InsertCommand.Connection != null)
if (this._dataAdapter.InsertCommand.Connection.Equals(this._transaction.Connection))
this._dataAdapter.InsertCommand.Connection = null;
}
if (_dataAdapter.UpdateCommand != null)
{
if (this._dataAdapter.UpdateCommand.Connection != null)
if (this._dataAdapter.UpdateCommand.Connection.Equals(this._transaction.Connection))
this._dataAdapter.UpdateCommand.Connection = null;
}
if (_dataAdapter.DeleteCommand != null)
{
if (this._dataAdapter.DeleteCommand.Connection != null)
if (this._dataAdapter.DeleteCommand.Connection.Equals(this._transaction.Connection))
this._dataAdapter.DeleteCommand.Connection = null;
}
}
//确保本对象的连接不是事务的连接,以免本对象Dispose时,意外关闭事务的连接。
if (this._connection != null)
{
if (this._connection.Equals(this._transaction.Connection))
this._connection = null;
}
//
this._transaction = null;
}
}
#endregion
【文件预览】:
Transaction.cs
DataBaseAccess.cs