Database related exception - GenericADOException

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MIkeyInterToExp
    New Member
    • May 2018
    • 1

    Database related exception - GenericADOException

    I'm currently trying to test my program, but I keep running into database related error.

    Code:
    NHibernate.Exceptions.GenericADOException: could not execute query ........ System.Transactions.TransactionException: The operation is not valid for the state of the transaction.
    I've searched everywhere online, as much asI could. I get different solutions pop up everywhere. But can't seem to be able to apply it to my problem. Not even sure if they share the issues I have.
    Any ideas why I could be getting this error?
    Background: (Narrowing it down to the surrounding issues - following the stack trace.) My application has a lot of modules/classes talking to each other. One class is responsible for populating the a DTO (data transfer object) with data obtained from other methods. All this within a foreach loop.
    It is very likely the loop is iterating over 1000 items. As a result, I felt maybe the database connection is timing out - not sure.
    But every time, I get this error

    Code:
    NHibernate.Exceptions.GenericADOException: could not execute query
    [ select TOP (1)  roleinfoin0_.InfoId as InfoId106_, roleinfoin0_.RoleId as RoleId106_, roleinfoin0_.EntityId as     EntityId106_, roleinfoin0_.Info as Info106_ from EntityRoleInfo roleinfoin0_, RoleAdditionalInfo roleinfo1_, RoleDef     roledef3_ where roleinfoin0_.RoleId=roleinfo1_.RoleId and roleinfoin0_.InfoId=roleinfo1_.InfoId and     roleinfo1_.RoleId=roledef3_.RoleId and roleinfoin0_.EntityId=? and roleinfo1_.Prompt=? and     roledef3_.RoleDescription=? ]
      Name:p1 - Value:120  Name:p2 - Value:Date of Birth  Name:p3 - Value:Client
    [SQL: select TOP (1)  roleinfoin0_.InfoId as InfoId106_, roleinfoin0_.RoleId as RoleId106_, roleinfoin0_.EntityId as     EntityId106_, roleinfoin0_.Info as Info106_ from EntityRoleInfo roleinfoin0_, RoleAdditionalInfo roleinfo1_, RoleDef     roledef3_ where roleinfoin0_.RoleId=roleinfo1_.RoleId and roleinfoin0_.InfoId=roleinfo1_.InfoId and     roleinfo1_.RoleId=roledef3_.RoleId and roleinfoin0_.EntityId=? and roleinfo1_.Prompt=? and     roledef3_.RoleDescription=?] ---> System.Transactions.TransactionException: The operation is not valid for the state     of the transaction.
       at System.Transactions.TransactionState.EnlistVolatile(InternalTransaction tx, IEnlistmentNotification     enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)
       at System.Transactions.Transaction.EnlistVolatile(IEnlistmentNotification enlistmentNotification,     EnlistmentOptions enlistmentOptions)
    Please guys, what am I possibly doing wrong. You should know that when I run that code (the method it crashes at) in isolation via test, it works fine.
    Thanks in advance.
Working...