public void Save() { System.Data.SqlClient.SqlConnection txnConn = DAL.ProfitRecordings.GetOpenConnection("CryptoTrades"); IDbTransaction Txn = txnConn.BeginTransaction(); try { // save alert row changes. DAL.DollarCostAvg dollarcostavg = new DAL.DollarCostAvg(); dollarcostavg.Txn = Txn; dollarcostavg.Save(ref _id, _theDate, _btcUsd, _btc, _usd); // commit transaction Txn.Commit(); } catch (Exception ex) { Txn.Rollback(); throw ex; } finally { txnConn.Close(); txnConn.Dispose(); Txn.Dispose(); } }