Hello Jason,
U can do it with transaction resource managers (resources that can be enlisted
in transaction), for example database
See this CodeSnippet
string connectionString = "...";
IDbConnection connection = new SqlConnection(connectionString);
connection.Open();
IDbCommand command = new SqlCommand();
command.Connection = connection;
IDbTransaction transaction;
transaction = connection.BeginTransaction(); //Enlisting database
command.Transaction = transaction;
try
{
/* Interact with database here, then commit the transaction */
transaction.Commit();
}
catch
{
transaction.Rollback(); //Abort transaction
}
finally
{
connection.Close();
}
JH> I am just wondering how do we test the transaction's Commit and
JH> Rollback? How do we simulate a situation to let the transaction fail
JH> then Rollback? Thanks for help.
---
WBR,
Michael Nemtsev :: blog:
http://spaces.msn.com/members/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch