TransactionScope error “ExecuteNonQuery requires an open and available Connection” in C# [duplicate]

☆樱花仙子☆ 提交于 2019-12-13 05:17:57

问题


Possible Duplicate:
asp.Net TransactionScope error

whenever I put TransactionScope, I got this error.

ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.

   using (TransactionScope scope = new TransactionScope())
   {

        ptDA.UpdateTC(InboundDS);
        ptDA.Addinventor(InboundDS);
        addressDA.AddAddress(InboundDS);
        scope.Complete();
  }

If I don't put the transaction scope , I don't get any error. This one runs well.

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

What's wrong with my transactionScope?


回答1:


Try opening your connection within the TransactionScope.



来源:https://stackoverflow.com/questions/8305024/transactionscope-error-executenonquery-requires-an-open-and-available-connectio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!