using (TransactionScope transactionscope = new TransactionScope())
{
try
{
function1(); //perform update on table
function2(); //perform update on table
transactionscope.Complete();
}
catch(Exception ex)
{
}
}
Code working fine with sqlclient provider but in case of oledb provider it gives error "New transaction cannot enlist in the specified transaction coordinator". Already enable DTC service on server.
You can not open connection in transaction more than one, so create connection object and open it outside of the transaction scope store it in session reuse it where you want within transaction, after transaction complete insure to close connection to avoid any issue.