I have some code thus:
private static void Delete(int PaxID)
{
using (SqlConnection conn = DataHelper.GetDBConnection())
{
using (SqlCommand cmd = DataHelper.GetSPCommand("spDeletePax",conn))
{
cmd.Parameters.AddWithValue("@PaxID", PaxID);
cmd.ExecuteNonQuery();
}
}
}
public static void DeletePaxes(List<int> ids, string bookingRef, string user)
{
using (TransactionScope ts = new DataHelper.CreateTransactionScope())
{
foreach (var i in ids)
{
Delete(i);
}
ts.Complete();
}
}
public static SqlConnection GetDBConnection()
{
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DB"].ConnectionString);
conn.Open();
return conn;
}
public static TransactionScope CreateTransactionScope()
{
var transactionOptions = new TransactionOptions();
transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
transactionOptions.Timeout = TransactionManager.MaximumTimeout;
return new TransactionScope(TransactionScopeOption.Required, transactionOptions);
}
which until recently was working fine I have changed no code, but simply changed my source control from VSS to SVN, and now opened up the project in VS2012 (instead of 2008).
If i call the DeletePaxes(..) the first delete works but the second times out when connecting to the DB
am i just doing this wrong or does 2012/.NET4/4.5 deal with transactions differently? I have done some googling and turned up nothing (hence posting here)
can anyone enlighten me as to what might be going on? am I just doing this wrongly?
DTC issetup so dont think its that - and like i say was working fine until I changed the source control.. also if i change the transaction to just the default - not using the static method, it also fails.. removing the transaction works fine I am using the transaction because I need ALL or NONE of the deletes to work..
thanks