我正在跨多個系統進行數據庫事務(插入記錄)。所以,我決定在.net中使用System.Transaction命名空間。我在兩個系統上配置了MSDTC(但我不知道我是否正確配置)。我的事務有兩個插入查詢一個將在本地系統執行。另一個將在本地網絡中的某個其他系統上執行。 第一次插入查詢成功,但第二次提出錯誤,如: Message =「該事務已被隱式或顯式提交或中止。」分佈式事務處理協調器
請幫助在這種情況下結束。
這裏是我的代碼
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();
}
}
你可以編輯我包括包含整個事務的代碼。 – Fung 2009-04-28 06:17:06