This IfxTransaction has completed; it is no longer usable

后端 未结 1 920
眼角桃花
眼角桃花 2021-01-23 07:46

Q:

When I use the transactions ,I\'ll get the following error on about 1 out of every 100 record.

This IfxTransaction has completed; it is no lo

相关标签:
1条回答
  • 2021-01-23 08:38

    You seem to be handling errors and rolling back the transaction in two places (in Execute_NonQueryWithTransaction and in InsertGroups.

    And the return from Execute_NonQueryWithTransaction is used both to return error codes and to return rows affected. But in InsertGroups it is checked purely as a rows affected.

    Could you have an error code from Execute_NonQueryWithTransaction (so transaction rolled back) being treated as success (rows inserted) in InsertGroups and the commit then fails?

    Overall the code needs significant cleanup:

    1. A catch block to only throw is pointless and just adds noise.
    2. Just use exceptions for error handling, all normal returns should indicate success.
    0 讨论(0)
提交回复
热议问题