一个简单的存储过程(实现事务执行两个sql语句,修改可实现执行更多条sql语句)

 //实现数据库事务
        public static void ExecuteSqlTran(string SQLString1, string SQLString2)
        {
            using (OracleConnection conn = new OracleConnection(_DBConnectionString))
            {
                conn.Open();
                OracleCommand cmd = new OracleCommand();
                cmd.Connection = conn;
                OracleTransaction tx = conn.BeginTransaction();
                cmd.Transaction = tx;
                try
                {
                    cmd.CommandText = SQLString1;
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = SQLString2;
                    cmd.ExecuteNonQuery();
                    tx.Commit();
                }
                catch (System.Data.OracleClient.OracleException E)
                {
                    tx.Rollback();
                    throw new Exception(E.Message);
                }
            }
        }

一个简单的存储过程(实现事务执行两个sql语句,修改可实现执行更多条sql语句),布布扣,bubuko.com

一个简单的存储过程(实现事务执行两个sql语句,修改可实现执行更多条sql语句)

上一篇:收藏:Python高阶读取Excel表格数据


下一篇:使用EntityFramework6.1的DbCommandInterceptor拦截生成的SQL语句