C# TransactionScope错误“;ExecuteOnQuery需要一个开放且可用的连接;在C中#

C# TransactionScope错误“;ExecuteOnQuery需要一个开放且可用的连接;在C中#,c#,transactionscope,C#,Transactionscope,可能重复: 每当我放置TransactionScope时,都会出现此错误 ExecuteOnQuery需要一个打开且可用的连接。 连接的当前状态为关闭。 using (TransactionScope scope = new TransactionScope()) { ptDA.UpdateTC(InboundDS); ptDA.Addinventor(InboundDS); addressDA.AddAddress(Inbound

可能重复:

每当我放置TransactionScope时,都会出现此错误

ExecuteOnQuery需要一个打开且可用的连接。 连接的当前状态为关闭。

   using (TransactionScope scope = new TransactionScope())
   {

        ptDA.UpdateTC(InboundDS);
        ptDA.Addinventor(InboundDS);
        addressDA.AddAddress(InboundDS);
        scope.Complete();
  }
如果我不放置事务范围,我不会得到任何错误。这台运行良好

        ptDA.UpdateTC(InboundDS);
        ptDA.Addinventor(InboundDS);
        addressDA.AddAddress(InboundDS);

我的transactionScope有什么问题?

请尝试在transactionScope中打开连接。

我们需要查看更多代码,特别是在与dataadapters关联的连接打开时。