how to manage transactions using DAAB ?

Topics: Data Access Application Block
May 31, 2010 at 12:30 PM


thanks for your attention, time and sharing.

I am using DAAB 4.0 with C# and SQL Server 2005. Please guide me how I can manage Transactions using DAAB when adding data in multiple tables ? I am using DAAB in the following way:


 public int SaveProductDetails(string Parameter1, string Parameter2)


             object objresult = db.ExecuteNonQuery("p_save_product", Parameter1,Parameter2);

              result = Int32.Parse(objresult.ToString());            

            return result;            


Thanks alot



Jun 1, 2010 at 2:06 AM

You would make use of TransactionScope class.  Make sure that you use the same instance of a TransactionScope object for those operations that you would want to include in the transaction.  Here's a related thread.

You could also make use of the overloads of ExecuteNonQuery that accepts a DbTransaction object.  Create a DbConnection object from your Database object and then make use of that connection object to create a DbTransaction object.  Again, you need to make use of a single instance of a DbTransaction object and call against it either Commit or Rollback.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.