. // Starts a transaction and inserts one record If insert fails, rolls back // the transaction Otherwise, commits the transaction .... string ConStr =. "User Id = myschema; Password = mypassword;" "Data Source = oracle "
OracleConnection Con = New OracleConnection (Constr);
C.Open ();
// Create An OracleCommand Object Using The Connection ObjectOracleCommand CMD = New OracleCommand ("", CON);
// Start a transactionoracletransaction txn = con.begintransaction; try {cmd.commandtext = "INSERT INTO MyTable Values (99, 'foo')"
cmd.commandtype = commandtype.text;
cmd.executenonquery ();
Txn.commit ();
Console.writeline ("Both Records Are INSERTED INTO The Database TABLE.")
} catch (exception e) {
Txn.rollback ();
Console.writeline ("Neither Record Was Inserted Into The Database Table.");
}