Hi...
In my scenerio , i have to insert data to master table and details table . For example consider the details given below.
Function 1 : Insert data to employee master table.
Function 2 : Insert gridview data to employee details table, here employee id from employee master table is needed to pass.
I want to this using 3 tier architetcure . I can call this only in Data access layer , and if any of the functions failed both tables must not be saved ,
can any one help me on this scenerio..
Thanks and Regards
Sankar
Loading
Jignesh TrivediPosted Jul 24, 2012, 2:15 AM
yes you can acheive this using transaction scope.
for same you must enable MSDTC on SQL Server.
using (TransactionScope scope = new TransactionScope())
{
...
...
...
// Complete is not called and the transaction is rolled back.
scope.Complete();
}
Please refer..
http://technet.microsoft.com/en-us/library/cc753510%28WS.10%29.aspx
http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx
hope this will help you.