这个SQL错误意味着什么

时间:2021-06-15 22:31:28

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

例外:“分布式事务已完成。要么在新事务中登记此会话,要么在NULL事务中登记”

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

这是在托管SQL200和Sql 2008的机器上运行的SProc内部进行的。

The C# code looks something like this

C#代码看起来像这样

(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

Sproc看起来像这样

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

1 个解决方案

#1


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

该错误是由于DB前端的约束失败引起的。您的事务正在回滚(意味着数据库没有发生任何事情)。

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

基本上,这是在交易中发生的错误,如果没有更多信息我们就无法轻易识别。发布您的查询。

#1


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

该错误是由于DB前端的约束失败引起的。您的事务正在回滚(意味着数据库没有发生任何事情)。

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

基本上,这是在交易中发生的错误,如果没有更多信息我们就无法轻易识别。发布您的查询。