using (var connection = new SqlConnection(connectionString)) { connection.Open(); using (var transaction = connection.BeginTransaction()) { try { // Perform database operations here transaction.Commit(); } catch (Exception e) { transaction.Rollback(); Console.WriteLine(e); } } }
using (var connection = new OracleConnection(connectionString)) { connection.Open(); using (var transaction = connection.BeginTransaction()) { try { // Perform database operations here transaction.Commit(); } catch (Exception e) { transaction.Rollback(); Console.WriteLine(e); } } }In this example, an OracleConnection object is created with a connection string. The rest of the code is similar to the previous example, except that the OracleConnection and OracleTransaction classes are used instead of SqlConnection and IDbTransaction. Package library: Oracle.ManagedDataAccess.Client