Can anyone please tell me what is the prefered way to manage transaction when using Enterprise Library's DAAB (version 4.1)? I was thinking about
Database NewDb = DatabaseFactory.CreateDatabase();
DBCommand NewCmd = NewDb.GetStoredProcCommand("SProcName");
/* Add parameters here. */
using (TransactionScope NewTrans = new TransactionScope())
{
NewDb.ExecuteNonQuery(NewCmd);
NewTrans.Complete()
}
but I don't know if I will be doing the right way.
TransactionScope is the preferred way to do transactional work in Enterprise Library. Your example is fine.
You do have the option to do manual transaction management - that's primarily in there for backwards compatibilty for older Entlib code.