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


C# OracleTransaction.Rollback方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:JuRogn,项目名称:OA,代码行数:41,代码来源:MsOracle.cs

示例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;
     }
 }
开发者ID:JuRogn,项目名称:OA,代码行数:34,代码来源:MsOracle.cs

示例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);
         }
     }
 }
开发者ID:JuRogn,项目名称:OA,代码行数:30,代码来源:MsOracle.cs

示例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];
        }
开发者ID:JuRogn,项目名称:OA,代码行数:41,代码来源:MsOracle.cs

示例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;
            }

        }
开发者ID:JuRogn,项目名称:OA,代码行数:37,代码来源:MsOracle.cs

示例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;
        }
开发者ID:JuRogn,项目名称:OA,代码行数:42,代码来源:OracleDataProvider.cs

示例7: Rollback

 /// <summary>
 /// 回滚事务
 /// </summary>
 /// <param name="transaction">事务对象</param>
 /// <param name="connection">连接对象</param>
 public static void Rollback(OracleTransaction transaction, OracleConnection connection)
 {
     transaction.Rollback();
     connection.Close();
 }
开发者ID:WuziyiaoKingIris20140501,项目名称:KFC,代码行数:10,代码来源:DbHelperOra.cs

示例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;
        }
开发者ID:JuRogn,项目名称:OA,代码行数:44,代码来源:MSOracle.cs

示例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;
            }

        }
开发者ID:JuRogn,项目名称:OA,代码行数:40,代码来源:MSOracle.cs


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