**
Okay , thanks for the anser. so what is the purposeof transactions if it isnt use for SQL? This article show an example of using simple transactions:
http://msdn.microsoft.com/en-us/library/ms172152(v=vs.90).aspx
what is the purpose of this if it isnt for rolling back what ever they trying to restore in case the code fail? and what is tge diff between ambient transaction and normal transaction?
void RootMethod()
{
using(TransactionScope scope = new TransactionScope())
{
/* Perform transactional work here */
SomeMethod();
scope.Complete();
}
}
void SomeMethod()
{
using(TransactionScope scope = new TransactionScope())
{
/* Perform transactional work here */
scope.Complete();
}
}
TransactionScope
is an ambient transaction for providers that detect and support it, such as ADO.NET database connection providers.
Not a magic wand to revert any changes you make inside your program. It just does not work this way.
If you create a TransactionScope
, then create a database connection, then do something to the database using that connection, and then rollback the transaction scope, your changes to the database will be undone as if you issued a ROLLBACK TRAN
against it.
Nothing more.