views:

277

answers:

1

Exception: "Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction"

This is hapening inside a SProc running on a machine having both SQL 2005 and Sql 2008 hosted.

The C# code looks something like this

(using TransactionScope t = new TransactionScope ())
{
   using(SqlConnection c= new SqlConnection(...))
   {
      c.Open();
      DataContext1 ctx = new DataContext1(c);//Linq2SQL
      c.StoreData(2,3);//Call Sproc
   }
}

Sproc Looks like this

Select * Table where x=2 and y=3
if(@@rowcount =0)
   Insert into table values(2,3)
end if
+3  A: 

That error is due to a constraint failure on DB front. Your transaction is being rolled back (meaning nothing is happening to the database).

Basically, it's an error occurring in a transaction that we can't readily identify without more information. Post your query.

Frank Crook
It's funny, I posted the exact same text from MSDN just after you did. Looked silly having the same post twice.
jerebear
@jerebear Haha. I guess it just seemed nicer to Google it, rather than saying 'Google it.' Maybe we should teach men to fish though?
Frank Crook