using (tgTransactionScope scope = new tgTransactionScope()) { // Logic here ... scope.Complete(); // last line of using statement }
Note that if an exception is thrown scope.Complete will not be called, and the transaction upon leaving the using statement will be rolled back. You indicate whether you want the provider to use the tgTransactionScope or the System.Transactions.TransactionScope class in your .config file. Notice in the config file setting below that providerClass="DataProvider". This indicates that you want to use the tgTransactionScope class, use providerClass="DataProviderEnterprise" to use System.Transactions.TransactionScope. <add name="SQL" providerMetadataKey="esDefault" sqlAccessType="DynamicSQL" provider="Tiraggo.SqlClientProvider" providerClass="DataProvider" connectionString="User ID=sa;Password=griffinski;Initial Catalog=Northwind;Data Source=localhost" databaseVersion="2005"/>