本文整理汇总了C#中System.Data.OracleClient.OracleTransaction.Rollback方法的典型用法代码示例。如果您正苦于以下问题:C# OracleTransaction.Rollback方法的具体用法?C# OracleTransaction.Rollback怎么用?C# OracleTransaction.Rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OracleClient.OracleTransaction
的用法示例。
在下文中一共展示了OracleTransaction.Rollback方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteReader
/// <summary>
/// 执行一个OracleCommand(返回一个结果OracleDataReader)
/// </summary>
/// <param name="connection">有效的 OracleConnection</param>
/// <param name="transaction">有效的 OracleTransaction, or 'null'</param>
/// <param name="commandType">命令类型 (stored procedure, text, etc.)</param>
/// <param name="commandText">存储过程名称或 PL/SQL</param>
/// <param name="commandParameters">以一个数组的形式返回OracleParameters </param>
/// <param name="connectionOwnership">indicates whether the connection parameter was provided by the caller, or created by OracleProvider</param>
/// <returns></returns>
private static OracleDataReader ExecuteReader(OracleConnection connection, OracleTransaction transaction, CommandType commandType, string commandText, OracleParameter[] commandParameters, OracleConnectionOwnership connectionOwnership)
{
OracleCommand cmd = new OracleCommand();
PrepareCommand(cmd, connection, transaction, commandType, commandText, commandParameters);
OracleDataReader dr = null;
try
{
if (connectionOwnership == OracleConnectionOwnership.External)
{
dr = cmd.ExecuteReader();
}
else
{
// dr = cmd.ExecuteReader((CommandBehavior)((int)CommandBehavior.CloseConnection));
dr = cmd.ExecuteReader();
}
if (transaction != null)
{
transaction.Commit();
}
return (OracleDataReader)dr;
}
catch
{
if (transaction != null)
{
transaction.Rollback();
}
throw;
}
}
示例2: ExecuteNonQuery
/// <summary>
///执行一个命令,没有返回数据集,只返回影响记录数
/// </summary>
/// <remarks>
/// 例如:
/// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "GetOrders", new OracleParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">有效的 OracleTransaction</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">存储过程名称或 PL/SQL</param>
/// <param name="commandParameters">OracleParameter[]</param>
/// <returns>影响记录数</returns>
public static int ExecuteNonQuery(OracleTransaction transaction, CommandType commandType, string commandText, params OracleParameter[] commandParameters)
{
OracleCommand cmd = new OracleCommand();
PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters);
try
{
int returnInt = cmd.ExecuteNonQuery();
if (transaction != null)
{
transaction.Commit();
}
return returnInt;
}
catch
{
if (transaction != null)
{
transaction.Rollback();
}
return 0;
}
}
示例3: RollbackTransaction
/// <summary>
/// 回滚事务
/// </summary>
public void RollbackTransaction(OracleConnection connObjection)
{
if (Transaction != null && Transaction.Connection == connObjection)
{
try
{
Transaction.Rollback();
Close(connObjection);
Transaction = null;
if (connObjection != null)
{
if (connObjection.State == ConnectionState.Open)
{
Close(connObjection);
}
}
}
catch (OracleException e)
{
Transaction.Rollback();
Close(connObjection);
Transaction = null;
LogHelper.WriteLog("MsOracle.RollbackTransaction(OracleConnection connObjection)", null, e);
throw new System.Exception(e.Message);
}
}
}
示例4: ExecuteTable
/// <summary>
/// 执行一个OracleCommand命令并返回结果集
/// </summary>
/// <remarks>
/// 例如:
/// DataTable ds = ExecuteDataTable(trans, CommandType.StoredProcedure, "GetOrders", new OracleParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">有效的 OracleTransaction</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">存储过程名称或 PL/SQL</param>
/// <param name="commandParameters">params OracleParameter[]</param>
/// <returns>返回DataSet</returns>
public static DataTable ExecuteTable(OracleTransaction transaction, CommandType commandType, string commandText, params OracleParameter[] commandParameters)
{
OracleCommand cmd = new OracleCommand();
PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters);
OracleDataAdapter da;
DataSet ds = new DataSet();
try
{
da = new OracleDataAdapter(cmd);
da.Fill(ds);
if (transaction != null)
{
transaction.Commit();
}
}
catch
{
if (transaction != null)
{
// Rollback the transaction
transaction.Rollback();
}
}
//return the dataset
return ds.Tables[0];
}
示例5: ExecuteScalar
/// <summary>
///返回结果集的第一行第一列
/// </summary>
/// <remarks>
/// 例如:
/// int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount", new OracleParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">有效的 OracleTransaction</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">存储过程T-OleDb的名称或命令</param>
/// <param name="commandParameters">params OracleParameter[]</param>
/// <returns>返回结果集的第一行第一列</returns>
public static object ExecuteScalar(OracleTransaction transaction, CommandType commandType, string commandText, params OracleParameter[] commandParameters)
{
OracleCommand cmd = new OracleCommand();
PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters);
try
{
object obj = cmd.ExecuteScalar();
if (transaction != null)
{
transaction.Commit();
}
return obj;
}
catch
{
if (transaction != null)
{
transaction.Rollback();
}
return null;
}
}
示例6: ExecuteDataset
/// <summary>
/// 执行一个OracleCommand命令并返回结果集;执行完成没有关闭OracleConnection连接,需要手动关闭
/// </summary>
/// <remarks>
/// 例如:
/// DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders", new OracleParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">有效的 OracleTransaction</param>
/// <param name="commandType">命令类型:SQL语句或存储过程</param>
/// <param name="commandText">存储过程名称或 PL/SQL</param>
/// <param name="commandParameters">params OracleParameter[]</param>
/// <returns>返回DataSet</returns>
public static DataSet ExecuteDataset(OracleTransaction transaction, CommandType commandType, string commandText, params OracleParameter[] commandParameters)
{
OracleCommand cmd = new OracleCommand();
PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters);
OracleDataAdapter da;
DataSet ds = new DataSet();
try
{
da = new OracleDataAdapter(cmd);
da.Fill(ds);
if (transaction != null)
{
transaction.Commit();
}
}
catch (System.Exception e)
{
if (transaction != null)
{
// Rollback the transaction
transaction.Rollback();
}
throw new System.Exception(e.Message, e);
}
//return the dataset
return ds;
}
示例7: Rollback
/// <summary>
/// 回滚事务
/// </summary>
/// <param name="transaction">事务对象</param>
/// <param name="connection">连接对象</param>
public static void Rollback(OracleTransaction transaction, OracleConnection connection)
{
transaction.Rollback();
connection.Close();
}
示例8: ExecuteDataset
/// <summary>
/// Execute an OracleCommand (that returns a resultset) against the specified OracleTransaction
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders", new OracleParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">有效的 OracleTransaction</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">存储过程名称或 PL/SQL</param>
/// <param name="commandParameters">params OracleParameter[]</param>
/// <returns>返回DataSet</returns>
public static DataSet ExecuteDataset(OracleTransaction transaction, CommandType commandType, string commandText, params OracleParameter[] commandParameters)
{
//create a command and prepare it for execution
OracleCommand cmd = new OracleCommand();
PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters);
//create the DataAdapter & DataSet
OracleDataAdapter da;
DataSet ds = new DataSet();
try
{
da = new OracleDataAdapter(cmd);
//fill the DataSet using default values for DataTable names, etc.
da.Fill(ds);
if (transaction != null)
{
transaction.Commit();
}
}
catch
{
if (transaction != null)
{
// Rollback the transaction
transaction.Rollback();
}
}
//return the dataset
return ds;
}
示例9: ExecuteScalar
/// <summary>
///返回结果集的第一行第一列
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount", new OracleParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">有效的 OracleTransaction</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">the stored procedure name or T-OleDb command</param>
/// <param name="commandParameters">params OracleParameter[]</param>
/// <returns>返回结果集的第一行第一列</returns>
public static object ExecuteScalar(OracleTransaction transaction, CommandType commandType, string commandText, params OracleParameter[] commandParameters)
{
//create a command and prepare it for execution
OracleCommand cmd = new OracleCommand();
PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters);
try
{
//execute the command & return the results
object obj = cmd.ExecuteScalar();
if (transaction != null)
{
transaction.Commit();
}
return obj;
}
catch
{
if (transaction != null)
{
// Rollback the transaction
transaction.Rollback();
}
return null;
}
}