// start a local transaction mytrans = myconnection.begintransaction(isolationlevel.readcommitted); // assign transaction object for a pending local transaction mycommand.transaction = mytrans;
try { mycommand.commandtext = "insert into dept (deptno, dname, loc) values (50, 'technology', 'denver')"; mycommand.executenonquery(); mycommand.commandtype= commandtype.storedprocedure; mycommand.commandtext="prc_test"; mycommand.executenonquery(); mytrans.commit(); console.writeline("both records are written to database."); } catch(exception e) { mytrans.rollback(); console.writeline(e.tostring()); console.writeline("neither record was written to database."); } finally { myconnection.close(); } }