I am trying make a database transaction(inserting records) across multiple system. So, I decided to use System.Transaction Namespace in .net. I configured MSDTC on both system(But i dont know whether i configured correctly). My transaction has two insert query one will execute at local system. another, will execute at some other system in a local network. First insert query work successfully but second one raise a error like : Message = "The transaction has already been implicitly or explicitly committed or aborted."
Please help in this case to over come.
Here is my Code
using (TransactionScope txSc = new TransactionScope())
{
//vrm = new VolatileRM();
//vrm.SetMemberValue(3);
try
{
using (SqlConnection cn = new SqlConnection(connStr1))
{
SqlCommand cmd = cn.CreateCommand();
cmd.CommandText = "Insert into empdetail Values ('YYY')";
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
using (SqlConnection cn = new SqlConnection(connStr))
{
SqlCommand cmd = cn.CreateCommand();
cmd.CommandText = "Insert into stu Values ('23','senthil')";
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
txSc.Complete();
}
catch (Exception e)
{
txSc.Dispose();
}
}