Close the connection after the transaction is completed. The full method.
ts.Complete(); con.Close();
completed code
using (System.Transactions.TransactionScope ts = new Sytem.Transactions.TransactionScope()) { try { foreach (DataRow row in this.dt1.Rows) { int titleId = int.Parse(row["titleId"].ToString()); string fname = row["fname"].ToString(); string lname = row["lname"].ToString(); if (cmd.Parameters.Count > 0) cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@titleId", titleId); cmd.Parameters.AddWithValue("@fname", fname); cmd.Parameters.AddWithValue("@lname", lname); cmd.ExecuteNonQuery(); } ts.Complete(); con.Close(); } catch (Exception ex) { } }
Thamotharan karuppiah
source share